728x90
반응형
728x170
■ ControlTemplate 엘리먼트를 사용해 Label 엘리먼트를 정의하는 방법을 보여준다.
▶ 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="TestProject"
FontFamily="나눔고딕코딩"
FontSize="16">
<Window.Resources>
<Color x:Key="DisabledForegroundColorKey">#ff888888</Color>
<Style x:Key="LabelStyleKey" TargetType="Label">
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Top" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Label">
<Border>
<ContentPresenter
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
RecognizesAccessKey="True" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground">
<Setter.Value>
<SolidColorBrush Color="{DynamicResource DisabledForegroundColorKey}" />
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<StackPanel
HorizontalAlignment="Center"
VerticalAlignment="Center">
<Label
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="48"
FontWeight="Bold"
IsEnabled="False"
Content="icodebroker.tistory.com" />
<Label
Style="{StaticResource LabelStyleKey}"
Margin="0 10 0 0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="48"
FontWeight="Bold"
IsEnabled="False"
Content="icodebroker.tistory.com" />
</StackPanel>
</Window>
728x90
반응형
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] ControlTemplate 엘리먼트 : PasswordBox 엘리먼트 정의하기 (0) | 2023.01.28 |
---|---|
[C#/WPF] ControlTemplate 엘리먼트 : NavigationWindow 엘리먼트 정의하기 (0) | 2023.01.28 |
[C#/WPF] ControlTemplate 엘리먼트 : Menu 엘리먼트 정의하기 (0) | 2023.01.28 |
[C#/WPF] ControlTemplate 엘리먼트 : ListView 엘리먼트 정의하기 (0) | 2023.01.27 |
[C#/WPF] ControlTemplate 엘리먼트 : ListBox 엘리먼트 정의하기 (0) | 2023.01.27 |
[C#/WPF] ControlTemplate 엘리먼트 : GroupBox 엘리먼트 정의하기 (0) | 2023.01.27 |
[C#/WPF] ControlTemplate 엘리먼트 : Frame 엘리먼트 정의하기 (0) | 2023.01.27 |
[C#/WPF] ControlTemplate 엘리먼트 : Expander 엘리먼트 정의하기 (0) | 2023.01.25 |
[C#/WPF] ControlTemplate 엘리먼트 : DocumentViewer 엘리먼트 정의하기 (0) | 2023.01.25 |
[C#/WPF] ControlTemplate 엘리먼트 : DatePicker 엘리먼트 정의하기 (0) | 2023.01.25 |
댓글을 달아 주세요