728x90
반응형
728x170
▶ MainWindow.xaml
<Window x:Class="TestProject.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="800"
Height="600"
Title="ControlTemplate 엘리먼트 : Button 엘리먼트 정의하기"
Background="Black"
FontFamily="나눔고딕코딩"
FontSize="16">
<Window.Resources>
<Path x:Key="ToggleFullScreenIconPathKey"
Data="
M 9.6560059 19.516005 L 12.484985 22.345999 6.414978 28.413002 10 32
0 32 0 21.999998 3.5849915 25.585007 z M 22.342987 19.512999
L 28.412994 25.585007 32 21.999998 32 32 22 32 25.584991
28.413002 19.513 22.345999 z M 22 0 L 32 0
32 10.000001 28.414978 6.4129991 22.342987 12.486002 19.513 9.6559991 25.584991 3.5849995
z M 0 0 L 10 0 6.414978 3.5849995 12.483978
9.6569986 9.6569824 12.485002 3.5849915 6.4129991 0 10.000001 z" />
<SolidColorBrush x:Key="CustomButtonHighlightSolidColorBrushKey" Color="#ffefefef" />
<Style x:Key="ModernButtonStyleKey" TargetType="{x:Type Button}">
<Setter Property="Width" Value="45"/>
<Setter Property="Height" Value="45"/>
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Padding" Value="12"/>
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="{StaticResource CustomButtonHighlightSolidColorBrushKey}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border
BorderThickness="0"
Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}">
<ContentPresenter x:Name="contentPresenter"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#22ffffff" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="#44ffffff" />
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid>
<Button Style="{DynamicResource ModernButtonStyleKey}">
<Path
Stretch="Uniform"
Data="{Binding Source={StaticResource ToggleFullScreenIconPathKey}, Path=Data}"
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}" />
</Button>
</Grid>
</Window>
728x90
반응형
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] TextBox 엘리먼트 : 입력한 텍스트가 없는 경우 배경 메시지 보여주기 (0) | 2020.09.07 |
---|---|
[C#/WPF] 1차 방정식 직선을 기준으로 대칭 포인트 구하기 (0) | 2020.09.06 |
[C#/WPF] PathGeometry 클래스 : CreateFromGeometry 정적 메소드를 사용해 패스 지오메트리 구하기 (0) | 2020.09.06 |
[C#/WPF] FFMPEG을 사용해 동영상 재생하기 (0) | 2020.09.06 |
[C#/WPF] ControlTemplate 엘리먼트 : ScrollViewer 엘리먼트 정의하기 (0) | 2020.09.03 |
[C#/WPF] ControlTemplate 엘리먼트 : Button 엘리먼트 정의하기 (0) | 2020.09.02 |
[C#/WPF] ControlTemplate 엘리먼트 : ToggleButton 엘리먼트 정의하기 (0) | 2020.09.02 |
[C#/WPF] ProgressBar 엘리먼트 : Style 속성을 사용해 커스텀 진행바 만들기 (0) | 2020.09.02 |
[C#/WPF] ControlTemplate 엘리먼트 : 막대 모양의 Thumb을 갖는 Slider 엘리먼트 정의하기 (0) | 2020.09.02 |
[C#/WPF] ControlTemplate 엘리먼트 : 둥근 고리 모양의 Thumb을 갖는 Slider 엘리먼트 정의하기 (0) | 2020.09.02 |
[C#/WPF] Path 엘리먼트 : 패스 미니 언어를 사용해 아이콘 만들기 (0) | 2020.08.31 |
댓글을 달아 주세요