Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/Shared/HandyControl_Shared/Controls/Input/PasswordBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@ public Brush CaretBrush

#endif

public PasswordBox() => CommandBindings.Add(new CommandBinding(ControlCommands.Clear, (s, e) => Clear()));
public PasswordBox()
{
CommandBindings.Add(new CommandBinding(ControlCommands.Clear, (s, e) => Clear()));
CommandBindings.Add(new CommandBinding(ControlCommands.Focus, (s, e) => Focus()));
}

public System.Windows.Controls.PasswordBox ActualPasswordBox { get; set; }

Expand Down Expand Up @@ -270,6 +274,12 @@ public void Clear()
_textBox.Clear();
}

public new void Focus()
{
ActualPasswordBox.Focus();
_textBox.Focus();
}

private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
{
if (!IsSafeEnabled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,6 @@ public static class ControlCommands
public static RoutedCommand More { get; } = new(nameof(More), typeof(ControlCommands));

public static RoutedCommand Toggle { get; } = new(nameof(Toggle), typeof(ControlCommands));

public static RoutedCommand Focus { get; } = new(nameof(Focus), typeof(ControlCommands));
}