Reputation: 4218
I have a simple control that has a masked text box:
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
...
<extToolkit:MaskedTextBox Mask="000-000-000" Text="{Binding SerialNumber, UpdateSourceTrigger=PropertyChanged}" />
I also have a key binding on the control:
<UserControl.InputBindings>
<KeyBinding Command="{Binding SearchCommand}" Gesture="Enter" />
</UserControl.InputBindings>
The problem is when SearchCommand is executed I need the value they entered in the masked text box as the criteria for the search. With a regular text box this is no problem but apparently the MaskedTextBox
control doesn't play well with PropertyChanged UpdateSourceTrigger
.
If I click someplace else (so it looses focus) and then press enter it works, but obviously I don't want to have to do that. Are there any good workarounds for this situation?
Upvotes: 0
Views: 2196
Reputation:
You must bind your property to the Value property not the Text.
http://wpftoolkit.codeplex.com/wikipage?title=MaskedTextBox&referringTitle=Documentation
Upvotes: 1