Friday, December 30, 2011

WPF : Issue with red border appearing for Error elements even when parent panel is collapsed/hidden


In WPF there is an issue when you are using default error temple to show red borders around textboxes/datepickers/combo-boxes or any databound control.

Untill you have the panel visible to you everything looks okay, but moment you collapse that panel or hide it, the red boxes around those controls remain visible.
You can get away with this problem in following 2 steps

Step 1) First you need to change default error template to have only AdornedElementPlaceHolder, you don’t need any other control in error template.

Step 2) Then you need to change Trigger for “Validation.HasError” property, to mark border for control with Red color as shown below.


No comments:

Post a Comment