PasswordBox 컨트롤
[MainPage.xaml]
<UserControl x:Class="RiaPasswordBox.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
<StackPanel x:Name="myStackPanel">
<PasswordBox PasswordChar="*" Foreground="Red"></PasswordBox>
</StackPanel>
</Grid>
</UserControl>
[MainPage.xaml.cs]
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace RiaPasswordBox
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(MainPage_Loaded);
}
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
// 코드 기반으로 암호 텍스트박스 설정
PasswordBox pwd = new PasswordBox();
// 주요 속성 지정
pwd.Foreground = new SolidColorBrush(Colors.Red);
pwd.FontSize = 30;
pwd.Password = "1234"; // TextBox는 Text속성
pwd.FontFamily = new FontFamily("malgun gothic");
pwd.PasswordChar = '?';
pwd.BorderBrush = new SolidColorBrush(Colors.Blue);
pwd.BorderThickness = new Thickness(5);
// 컨트롤/레이아웃에 추가
this.myStackPanel.Children.Add(pwd);
}
}
}