Home > Uncategorized > Simple textbox validation

Simple textbox validation

The thing that i really get out of this is the UpdateSourceTrigger – i always forget that bit.

For this example, pretend you have a class which holds an integer. Go ahead and bind the textbox to that integer.

How do you validate that an integer is being typed in, as it is being typed?

easy:

<TextBox Height="23" Margin="94,0,64,93" Name="TextBox2" VerticalAlignment="Bottom">
<TextBox.Text>
<Binding Path="Age" UpdateSourceTrigger="PropertyChanged" >
<Binding.ValidationRules>
<ExceptionValidationRule/>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: