修正PanelLocker和PanelLockerPasswordChanger控件显示后焦点没有自动设置在密码输入框中的问题。

This commit is contained in:
DESKTOP-GPE37UV\THINKAPD 2023-04-04 10:13:05 +08:00
parent 860b96e242
commit 0d85a7840a
4 changed files with 21 additions and 5 deletions

View File

@ -24,7 +24,6 @@
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
MaxLength="15" Grid.Row="1"
FocusManager.FocusedElement="{Binding RelativeSource={RelativeSource Self}}"
PreviewKeyDown="TxtPass_OnPreviewKeyDown"/>
<TextBlock x:Name="txtInfo" Grid.Row="2" Grid.ColumnSpan="3" FontSize="9" HorizontalAlignment="Center" Margin="0,5,0,0" FontStyle="Italic" Foreground="Red"/>
<Button

View File

@ -66,6 +66,19 @@ namespace MECF.Framework.UI.Client.Ctrlib.Controls
Dispatcher.Invoke(Lock);
return true;
}, "AutoLockRecipeEditor");
Loaded += (sender, args) =>
{
txtPass.Focus();
};
IsVisibleChanged += (sender, args) =>
{
if (args.NewValue is bool isVis && isVis)
{
txtPass.Focus();
}
};
}
#region Dps
@ -132,6 +145,8 @@ namespace MECF.Framework.UI.Client.Ctrlib.Controls
#region Methods
public void Lock()
{
txtPass.Password = "";
@ -263,8 +278,5 @@ namespace MECF.Framework.UI.Client.Ctrlib.Controls
}
#endregion
}
}

View File

@ -39,7 +39,7 @@
<TextBlock Grid.Row="1" Text="New Password"/>
<TextBlock Grid.Row="2" Text="Confirm Password"/>
<PasswordBox x:Name="txtOldPass" Grid.Row="0" Grid.Column="1" FocusManager.FocusedElement="{Binding RelativeSource={RelativeSource Self}}"/>
<PasswordBox x:Name="txtOldPass" Grid.Row="0" Grid.Column="1" />
<PasswordBox x:Name="txtNewPass" Grid.Row="1" Grid.Column="1" />
<PasswordBox x:Name="txtConfirmPass" Grid.Row="2" Grid.Column="1" />

View File

@ -23,6 +23,11 @@ namespace MECF.Framework.UI.Client.Ctrlib.Controls
public PanelLockerPasswordChanger()
{
InitializeComponent();
Loaded += (sender, args) =>
{
txtOldPass.Focus();
};
}
private void btnOk_Click(object sender, RoutedEventArgs e)