MainPage.xaml
<Page
x:Class="UniversalAppTutorials.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UniversalAppTutorials"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<StackPanel
x:Name="stack_panel1"
Orientation="Vertical"
Background="GhostWhite"
Padding="100"
>
<TextBlock
x:Name="TextBlock1"
Foreground="Crimson"
Margin="15"
FontSize="20"
/>
<PasswordBox
x:Name="PasswordBox1"
Header="Password"
PlaceholderText="Input your password."
Width="300"
MaxLength="20"
PasswordChar="#"
PasswordRevealMode="Peek"
PasswordChanged="PasswordBox1_PasswordChanged"
/>
</StackPanel>
</Page>
MainPage.xaml.cs
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml;
namespace UniversalAppTutorials
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
private void PasswordBox1_PasswordChanged(object sender, RoutedEventArgs e)
{
// Cast the sender as a PasswordBox
PasswordBox passwordBox = sender as PasswordBox;
// Get the PasswordBox inputted string length
int length = passwordBox.Password.Length;
if (length > 0)
{
TextBlock1.Text = length + " Character(s).";
}
else {
TextBlock1.Text = "Your password entry box is empty.";
}
}
}
}




- UWP - CalendarDatePicker example
- UWP - TimePicker example
- UWP - Format DatePicker selected date
- UWP - DatePicker example
- UWP - ComboBox item style example
- UWP - Get ComboBox selected value
- UWP - ComboBox ItemsSource example
- UWP - Simple Flyout example
- UWP - Simple ContentDialog example
- UWP - HyperlinkButton example
- UWP - Show image and text on a Button
- UWP - Simple MessageDialog example
- UWP - Remove control programmatically
- UWP - CheckBox group example
- UWP - Button click event