Skip to content

Commit 6e59c50

Browse files
authored
Update PasswordBoxPage.xaml.cs to in line with latest change
1 parent 3bca632 commit 6e59c50

File tree

1 file changed

+43
-6
lines changed

1 file changed

+43
-6
lines changed

source/iNKORE.UI.WPF.Modern.Gallery/Pages/Controls/Windows/PasswordBoxPage.xaml.cs

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Text;
44
using System.Windows;
@@ -10,6 +10,8 @@
1010
using System.Windows.Media.Imaging;
1111
using System.Windows.Navigation;
1212
using System.Windows.Shapes;
13+
using iNKORE.UI.WPF.Modern.Common;
14+
using iNKORE.UI.WPF.Modern.Controls;
1315
using iNKORE.UI.WPF.Modern.Controls.Helpers;
1416

1517
namespace iNKORE.UI.WPF.Modern.Gallery.Pages.Controls.Windows
@@ -29,6 +31,36 @@ private void Page_Loaded(object sender, RoutedEventArgs e)
2931
UpdateExampleCode();
3032
}
3133

34+
private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
35+
{
36+
if (sender is PasswordBox pb)
37+
{
38+
if (string.IsNullOrEmpty(pb.Password) || pb.Password == "Password")
39+
{
40+
Control1Output.Visibility = Visibility.Visible;
41+
Control1Output.Text = "'Password' is not allowed.";
42+
pb.Password = string.Empty;
43+
}
44+
else
45+
{
46+
Control1Output.Text = string.Empty;
47+
Control1Output.Visibility = Visibility.Collapsed;
48+
}
49+
}
50+
}
51+
52+
private void RevealModeCheckbox_Changed(object sender, RoutedEventArgs e)
53+
{
54+
if (revealModeCheckBox.IsChecked == true)
55+
{
56+
PasswordBoxHelper.SetPasswordRevealMode(passwordBoxWithReveal, PasswordRevealMode.Visible);
57+
}
58+
else
59+
{
60+
PasswordBoxHelper.SetPasswordRevealMode(passwordBoxWithReveal, PasswordRevealMode.Hidden);
61+
}
62+
}
63+
3264
private void RadioButtons_SelectionChanged(object sender, SelectionChangedEventArgs e)
3365
{
3466
UpdateExampleCode();
@@ -43,17 +75,22 @@ public void UpdateExampleCode()
4375

4476
Example1.Xaml = Example1Xaml;
4577
Example2.Xaml = Example2Xaml;
78+
Example3.Xaml = Example3Xaml;
4679
}
4780

4881
public string Example1Xaml => $@"
49-
<PasswordBox/>
82+
<PasswordBox Width=""300"" AutomationProperties.Name=""Simple PasswordBox""/>
5083
";
5184

5285
public string Example2Xaml => $@"
53-
<PasswordBox x:Name=""passwordBox""
54-
ui:ControlHelper.Header=""Password"" PasswordChar=""#""
55-
ui:ControlHelper.PlaceholderText=""Enter your password""
56-
ui:PasswordBoxHelper.PasswordRevealMode=""{PasswordBoxHelper.GetPasswordRevealMode(passwordBox)}"" />
86+
<PasswordBox x:Name=""passwordBox"" Width=""300"" ui:ControlHelper.Header=""Password"" ui:ControlHelper.PlaceholderText=""Enter your password"" PasswordChar=""#"" />
87+
";
88+
89+
public string Example3Xaml => $@"
90+
<PasswordBox x:Name=""passwordBoxWithReveal"" Width=""250"" Margin=""0,0,8,0""
91+
ui:PasswordBoxHelper.PasswordRevealMode=""Hidden"" AutomationProperties.Name=""Sample password box""/>
92+
<CheckBox x:Name=""revealModeCheckBox"" Content=""Show password"" IsChecked=""False""
93+
Checked=""RevealModeCheckbox_Changed"" Unchecked=""RevealModeCheckbox_Changed""/>
5794
";
5895

5996
#endregion

0 commit comments

Comments
 (0)