diff --git a/src/MaterialDesignThemes.Wpf/PasswordBoxAssist.cs b/src/MaterialDesignThemes.Wpf/PasswordBoxAssist.cs index bee25b856d..93e0206a3a 100644 --- a/src/MaterialDesignThemes.Wpf/PasswordBoxAssist.cs +++ b/src/MaterialDesignThemes.Wpf/PasswordBoxAssist.cs @@ -19,6 +19,11 @@ public static class PasswordBoxAssist public static void SetIsPasswordRevealed(DependencyObject element, bool value) => element.SetValue(IsPasswordRevealedProperty, value); public static bool GetIsPasswordRevealed(DependencyObject element) => (bool)element.GetValue(IsPasswordRevealedProperty); + public static readonly DependencyProperty IsRevealButtonTabStopProperty = DependencyProperty.RegisterAttached( + "IsRevealButtonTabStop", typeof(bool), typeof(PasswordBoxAssist), new PropertyMetadata(true)); + public static void SetIsRevealButtonTabStop(DependencyObject element, bool value) => element.SetValue(IsRevealButtonTabStopProperty, value); + public static bool GetIsRevealButtonTabStop(DependencyObject element) => (bool)element.GetValue(IsRevealButtonTabStopProperty); + public static readonly DependencyProperty PasswordProperty = DependencyProperty.RegisterAttached( "Password", typeof(string), typeof(PasswordBoxAssist), new FrameworkPropertyMetadata(null, HandlePasswordChanged) { BindsTwoWayByDefault = true, DefaultUpdateSourceTrigger = UpdateSourceTrigger.LostFocus }); public static void SetPassword(DependencyObject element, string value) => element.SetValue(PasswordProperty, value); diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.PasswordBox.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.PasswordBox.xaml index 16479cdae9..86f6134ff0 100644 --- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.PasswordBox.xaml +++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.PasswordBox.xaml @@ -884,6 +884,7 @@ (""" + + + + + """); + + var passwordBox = await stackPanel.GetElement("PasswordBox"); + var textBox = await stackPanel.GetElement("TextBox"); + + // Assert Tab forward + await passwordBox.MoveKeyboardFocus(); + Assert.True(await passwordBox.GetIsKeyboardFocused()); + await passwordBox.SendKeyboardInput($"{Key.Tab}"); + Assert.True(await textBox.GetIsKeyboardFocused()); + + // Assert Tab backwards + await textBox.SendKeyboardInput($"{ModifierKeys.Shift}{Key.Tab}{ModifierKeys.None}"); + Assert.True(await passwordBox.GetIsKeyboardFocused()); + + recorder.Success(); + } }