views:

22

answers:

1

I'm using the MaskedTextbox for .NET 3.5 SP1, from the WPF toolkit. I've got a MaskedTextbox on a WPF page, it fills fine from a SQL Server database, but when I tried to edit the value nothing at all happens. I can select anything, but typing over it, or pressing the delete key or anything else I can thing of, does nothing to the value there. I want to use this to allow a user to enter or edit a time value, like this: 9:30 AM would appear as "09:30 AM". Here's the XAML that I've specified:

<cusControls:MaskedTextBox x:Name="mtbTime"
        Mask="90:00 >LL" Margin="5,0,0,0"
        Text="{Binding ElementName=ThisDateTime,Path=TimePart,Converter={StaticResource NullableTimeToUnderscoreConverter}}" />

(This is a part of a user control I'm making called "ThisDateTime".) What am I doing wrong and how do I fix it?

+1  A: 

I haven't seen the source for the text box, but ran into something similar myself.

  • Could it be a problem with your partially-entered text either not matching the mask, or not matching the converter?
  • Is the UpdateSourceTrigger on the Binding somehow set to UpdateProperty, or is something similar happening in the code-behind?
Lunivore
I asked a Microsoft tech about this, and you're correct, it did have something to do with the partially entered text not matching the mask.But what is the UpdateSourceTrigger that you're describing with the UpdateProperty? (I'm still too new to WPF to know all of its ins and outs.)
Rod
UpdateSourceTrigger is a value you can set to tell the text box when to update the source to which it's bound. Normally it only updates the source when the focus moves to another element in the same group (really annoying if you click on a different tab because you lose your text!) Setting it to UpdateProperty means it will update the source whenever the text changes in the text box.
Lunivore