Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Persisting state when using Tab Control

$
0
0

 

I have a page with a tabControl consisting of two TabItems : TabItem-1 and TabItem-2. In my TabItem-1 I have a TextBox control (MyTextBox), the content of which I'm TwoWay binding to a business entity's property. Now my textBox uses a template defined in a Style and the style also has a trigger set where if the Validation.HasErrors property is true, change the Template of the TextBox to ErrorTemplate which basically shows an error indicator next to the Textbox Control. Everything works fine so far.

 

Now I have editted the content of MyTextBox to have an invalid data so that the Error indicator shows up next to the control. Next if I go to TabItem-2 and then come back to TabItem-1, the content in the TextBox is the same as what it was before but the error indicator disappeared. It looks like the TextBox is using the default Template rather than the Error Template. Why is this happening the way it is? Is the engine clearing the ErrorCollection for the TextBox control? Is there a way to persist the state of the TabItem?

 

Thanks


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>