What is the event I should subscribe to in order to get TextBox
's Text
in the event args?
I've tried PreviewTextInput
, but if input string is, for example, "122." the box's (see code) text is without the dot but eventArgs.Text is "." and the input string validating successfully and TextBox.Text is "122..". What I want to do is to validate if the input string is decimal by calling decimal.TryParse
.
private void OnPreviewTextInput(object sender, TextCompositionEventArgs eventArgs)
{
var box = sender as TextBox;
if (box == null) return;
eventArgs.Handled = !ValidationUtils.IsValid(box.Text + eventArgs.Text);
}