Windows 10 中的 PasswordBox 奇怪行为

PasswordBox weird behaviour in Windows 10

我正在尝试在我的 Windows 10 通用应用程序中使用 PasswordBox。我面临的问题是,如果我在用户有任何机会输入之前用一些文本预填充 PasswordBox,则显示按钮将不再显示。如果我在应用程序 运行 时填充 PasswordBox,则不会发生这种情况。我也尝试了 with/without 推荐的 PasswordRevealMode 和弃用的 IsPasswordRevealButtonEnabled,但没有成功。

这是一个演示问题的小片段:

<StackPanel>
    <TextBlock Text="Pre-populated:"/>
    <PasswordBox x:Name="PrePopulatedPasswordBox"
        PasswordRevealMode="Peek"
        Password="123456"
    />
    <TextBlock Text="Type to populate"/>
    <PasswordBox x:Name="PopulatedWhenRunningPasswordBox"/>
</StackPanel>

我不认为这是预期的行为(据我从这里了解到:https://msdn.microsoft.com/en-uS/office/office365/windows.ui.xaml.controls.passwordbox.aspx

查看 PasswordRevealMode 属性 documentation,这似乎是已知行为:

If the PasswordBox loses focus and then regains focus, the reveal button is not shown again unless the password is cleared and character entry starts over.

由于该字段是预填充的,除非密码字段发生变化,否则不会显示显示按钮。也许这不是最好的行为,但它确实是 "working as designed".