Visual Studio/WPF > 컨트롤 > PasswordBox

운영 환경
Windows 7 Pro (32bit)
Microsoft Visual Studio 2017 Community
Sublime Text 2

PasswordBox를 사용해 보았습니다.

참고 : [스토어 앱] [입문] Step36. PasswordBox 컨트롤 사용 ~ 기본 사용법 ~ @ HIRO's .NET씨

MainWindow.xaml
<Window x:Class="_170501_t0650_doSomething.MainWindow"
        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"
        xmlns:local="clr-namespace:_170501_t0650_doSomething"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <PasswordBox x:Name="passbox1" HorizontalAlignment="Left" Margin="47,67,0,0" VerticalAlignment="Top" Width="164"/>
        <Button Content="Button" Click="Button_Click"
                HorizontalAlignment="Left" Margin="47,120,0,0" VerticalAlignment="Top" Width="75"/>

    </Grid>
</Window>

MainWindow.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace _170501_t0650_doSomething
{
    /// <summary>
    /// MainWindow.xaml の相互作用ロジック
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string msg = passbox1.Password;
            MessageBox.Show(msg);
        }
    }
}



좋은 웹페이지 즐겨찾기