Shaggy
Shaggy

Reputation: 73

wpf data validation control template - Not getting reflected when used on multiple pages

I am trying to use wpf data validation as shown in link below. In WPF, How to display validation error in TextBox like the image below? The problem that I am facing is, I have a Title text box on first and last page of my application. For both the pages viewmodel used is same and both the controls are bound to same property. I applied control template to both of them as shown, but somehow that validation part gets applied to only first text box, when I go to last page I cannot see the error on validation. It is default textbox without any validation shown on it. My validation is simple textbox empty validation.

Also when I comeback from last page to first page my control template validation is gone from first page also. Textbox that I am using is from WPF.Extended.Toolkit.dll (WatermarkTextBox) Any idea what could be the reason?

Upvotes: 0

Views: 173

Answers (1)

blindmeis
blindmeis

Reputation: 22445

try to wrap your textbox or the container with your textbox in a AdornerDecorator element.

<UserControl>
 <AdornerDecorator>
  <Grid>
   <TextBox/>
  </Grid>
 </AdornerDecorator>
</UserControl>

Upvotes: 1

Related Questions