I want to write a user control to enter a new password. This should be visible as a button "Change password" in my view and when the user clicks on that button, it should be replaced by a PasswordBox
and the two buttons Save
and Discard
. When the user clicks the Save
button a method in the DataContext
should be called with the new password as parameter.
My problem is, that there also must be something like an overlay, that disables the rest of the view, when the password user control is in the "change password state" and that I have to show a vitual keyboard below on that overlay below the PasswordBox
.
I'm looking for a hint, which way to go. I think an Adorner
should do this, but I'm new to WPF and don't know, if thats't the right way.
I don't want to create a popup. I want to show the PasswordBox
right there, where the "Change password" button has been.
EDIT:
Right now, I have it like this:
<TextBlock Grid.Column="0" Grid.Row="2" Text="{lex:LocText Password}"/>
<Button Grid.Column="2" Grid.Row="2" Visibility="{Binding IsPasswordBoxVisible, Converter={StaticResource NegatedBooleanVisibilityConverter}}" Command="{Binding ShowPasswordBoxCommand}" Content="{lex:LocText SetNewPassword}"/>
<PasswordBox Grid.Row="2" Grid.Column="2" Visibility="{Binding IsPasswordBoxVisible, Converter={StaticResource BooleanVisibilityConverter}}" ... />
The PasswordBox
should appear at the same place, where it is now, but on top of an overlay (and with two buttons "save" and "cancel" next to it).
This takes attached property Panel.ZIndex to place the "Overlay" on top of everything else. You can either set the Visibility of the "Overlay" in code or use a DataTrigger.
If you are using a Canvas or Grid in your layout, give the control to be put on top a higher ZIndex
Updated Code: