728x90
반응형
728x170
■ ControlTemplate 엘리먼트를 사용해 PasswordBox 엘리먼트를 정의하는 방법을 보여준다.
▶ 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"
Background="Green"
FontFamily="나눔고딕코딩"
FontSize="16">
<Window.Resources>
<Color x:Key="ControlLightColorKey">White</Color>
<Color x:Key="BorderMediumColorKey">#ff888888</Color>
<Style x:Key="{x:Type PasswordBox}" TargetType="{x:Type PasswordBox}">
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="MinWidth" Value="120" />
<Setter Property="MinHeight" Value="20" />
<Setter Property="AllowDrop" Value="true" />
<Setter Property="SnapsToDevicePixels" Value="true" />
<Setter Property="KeyboardNavigation.TabNavigation" Value="None" />
<Setter Property="PasswordChar" Value="*" />
<Setter Property="FontFamily" Value="Verdana" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type PasswordBox}">
<Border Name="border"
CornerRadius="2"
BorderThickness="1"
Padding="2">
<Border.Background>
<SolidColorBrush Color="{DynamicResource ControlLightColorKey}" />
</Border.Background>
<Border.BorderBrush>
<SolidColorBrush Color="{DynamicResource BorderMediumColorKey}" />
</Border.BorderBrush>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup Name="CommonStates">
<VisualState Name="Normal" />
<VisualState Name="Disabled" />
<VisualState Name="MouseOver" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<ScrollViewer Name="PART_ContentHost" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<PasswordBox
HorizontalAlignment="Center"
VerticalAlignment="Center"
Width="300"
PasswordChar="#" />
</Window>
728x90
반응형
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] ControlTemplate 엘리먼트 : Slider 엘리먼트 정의하기 (0) | 2023.02.06 |
---|---|
[C#/WPF] ControlTemplate 엘리먼트 : ScrollViewer 엘리먼트 정의하기 (0) | 2023.01.31 |
[C#/WPF] ControlTemplate 엘리먼트 : ScrollBar 엘리먼트 정의하기 (0) | 2023.01.29 |
[C#/WPF] ControlTemplate 엘리먼트 : RepeatButton 엘리먼트 정의하기 (0) | 2023.01.29 |
[C#/WPF] ControlTemplate 엘리먼트 : ProgressBar 엘리먼트 정의하기 (0) | 2023.01.29 |
[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 엘리먼트 : Label 엘리먼트 정의하기 (0) | 2023.01.27 |
댓글을 달아 주세요