1

を使用しPasswordBoxていPageます。ワークフローが実装されているため、ユーザーはサブページ ( ) に移動してから、メイン ページにNavigationWindow戻ることができます。GoBack()

しかし、そうすると、パスワード ボックスは常に空になります。私の仕事はその行動を防ぐことですが、現時点ではそれを達成する方法がわかりません.

助けていただければ幸いです。ありがとう

4

2 に答える 2

2

特徴です。

参照: MVVM で PasswordBox にバインドする方法

後方ナビゲーションを有効にするには、ページの状態を保存する必要があります。そして、それは安全ではありません。

于 2012-05-28T11:07:31.753 に答える
0

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/

于 2015-08-11T11:49:47.773 に答える