hello , dear
how i can set validation to textBox runtime
i usnig this code but not get any result
this code in XAML is working
Text="{Binding CustName, Mode=TwoWay, NotifyOnValidationError=True, UpdateSourceTrigger=Default, ValidatesOnExceptions=True}"
but in code behaind not working
var pCustName= new Binding(DataValidation.MandatoryFields.ValidEmpty)
{
Path = new PropertyPath("Text"),
ElementName = DataValidation.MandatoryFields.CustName,
Mode = BindingMode.TwoWay,
UpdateSourceTrigger = UpdateSourceTrigger.Default,
ValidatesOnExceptions = true,
NotifyOnValidationError = true
};
txtCustName.SetBinding(TextBox.TextProperty, pCustName);
greeting
sayed eltokhy
Answer: 1
you were creating a binding that bound to "Text", but in xaml you're binding to "CustName". also, in code you're forcing it to look at an element, which your xaml doesn't do. this might work better:
var pCustName= new Binding(DataValidation.MandatoryFields.ValidEmpty)
{
Path = new PropertyPath("CustName"),
Mode = BindingMode.TwoWay,
UpdateSourceTrigger = UpdateSourceTrigger.Default,
ValidatesOnExceptions = true,
NotifyOnValidationError = true
};
txtCustName.SetBinding(TextBox.TextProperty, pCustName);
Answer: 2
Hi, please refer to this post: http://forums.silverlight.net/t/247948.aspx/1
Hope this will help you.
No comments:
Post a Comment
Send us your comment related to the topic mentioned on the blog