を使用しPasswordBox
ていPage
ます。ワークフローが実装されているため、ユーザーはサブページ ( ) に移動してから、メイン ページにNavigationWindow
戻ることができます。GoBack()
しかし、そうすると、パスワード ボックスは常に空になります。私の仕事はその行動を防ぐことですが、現時点ではそれを達成する方法がわかりません.
助けていただければ幸いです。ありがとう
を使用しPasswordBox
ていPage
ます。ワークフローが実装されているため、ユーザーはサブページ ( ) に移動してから、メイン ページにNavigationWindow
戻ることができます。GoBack()
しかし、そうすると、パスワード ボックスは常に空になります。私の仕事はその行動を防ぐことですが、現時点ではそれを達成する方法がわかりません.
助けていただければ幸いです。ありがとう
I don't think his exact problem is a feature, but a bug of the navigation service.
In your code behind you have no easy way to distinguish between the navigation control blanking your password on navigation or the user blanking it by deleting it from the box. So if you don't consider that, your password in your viewmodel will always be blank if you navigate to another page.
I used this hack to determine who called my password changed handler to update the view model:
private void PasswordBox_OnPasswordChanged(object sender, RoutedEventArgs e)
{
StackTrace stack = new StackTrace();
StackFrame[] stackframes = stack.GetFrames();
foreach (StackFrame stackFrame in stackframes)
if(stackFrame.GetMethod().Name == "Navigate")
return;
ViewModelPassword = PasswordBox.SecurePassword;
....
Take a look here too: http://www.wpfsharp.com/2011/04/08/wpf-navigationservice-blanks-passwordbox-password-which-breaks-the-mvvm-passwordhelper/