Quantcast
Channel: And again about Validation Rule
Viewing all articles
Browse latest Browse all 5

And again about Validation Rule

$
0
0

Good day

I'm already read many articles about validation rules, but....
Before this case I use ValidationRule in custom form or inside UserControl which also hosted on form.

At this moment I need something more complex. One of the product (SCSM) has an ability to add another UserControlsdynamically. SCSM has a hosted from, inside that form placed UserControl (also belong to SCSM). That control read the config data from XML and create other controls listed in config file. I don't know exactly the moment then it create the controls: at load or inside consctructor.

After that we get visual tree look like that (simplified):

Form
|
|->UserControl (SCSM)
           |
           |-> UserControl (my)

Problem: my custom UserControl never run validation rule then form opened first time.

For example, I have a TextBox inside of my UserControl. Text property of the TextBox bind to some property in DataContext. To binding added validation rule (simple validation rule, I'm already check my own rules and standard rules with same result). That rule check if value is empty. Then form with my control is opened validation not fired. If I type something inside of control and then delete validation rule fired.

I"m already try to use "((Control)sender).GetBindingExpression(TextBox.TextProperty).UpdateSource()" in Loaded event handler of TextBox (if I add this to LostFocus then validation also working).

Any idea how to make validation work on form loaded?


http://freemanru.wordpress.com/ freemanru (at) gmail (dot) com

Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles





Latest Images