Silverlight validation. Problem with email validation

I have text box and i want to validate is valid email in textbox on button "save" click.

But standard validation have strange behaviour. When i print new email it always with error and this is wery annoing. I want to show error only after button click and then text box must become valid if got focus. Is there are standard way to do this in THE MODEL-VIEW-VIEWMODEL.

Answers


The default behavior for changing the bound value in a TextBox is via LostFocus. You would need to change the UpdateSourceTrigger to be explicit.

<TextBox Name="MyTextBox"
         Text="{Binding Path=FirstName, UpdateSourceTrigger=Explicit}" />

Then in your code behind you now have to explicitly call UpdateSource via your Button click handler.

BindingExpression be = MyTextBox.GetBindingExpression(TextBox.TextProperty);
be.UpdateSource();

Need Your Help

knockout.js foreach binding within table

javascript knockout.js knockout-2.0

I am new to knockout.js and trying to figure why the next code yields exception, while seeming to be valid knockout binding.