Hello I'm trying to handle开发者_运维技巧 the user's input to the TextBox in Silverlight. I need to catch the text that's been entered and if it is not valid dismiss it. I've tried processing KeyDown and TextInputStart events, but the text gets updated after them. What should I do?
I think you better use Silverlight Validation with MVVM.
But if you prefer events, you can use the TextChanged Event to get every new character.
You can cast the sender
in order the get the TextBox
and use it's Text
property.
For example:
Dim l_textBox As TextBox = CType(sender, TextBox)
if l_textBox.Text = "ThisIsGoodString" Then
... Do something ...
End If
(VB.NET code)
精彩评论