Recently hit a WPF issue with IDataErrorInfo where using ValidatesOnDataErrors with a TextBox creates a border around the textbox that doesn’t go away when used with an Expander. Screen shot below before closing expander: 

Screenshot after closing expander:


 

The workaround?  Create a style for Textbox (or TextboxBase, depending) which blows away the validation error template like this:

<Setter Property="Validation.ErrorTemplate" Value="{x:Null}"/>

And then manually sets the border, like this:

<Setter Property="ToolTip"
Value="{Binding RelativeSource={x:Static RelativeSource.Self},
Path=(Validation.Errors)[0].ErrorContent}"/>
<Setter TargetName="Border" Property="Background" Value="Red"/>
</Trigger>

That did the trick. Download a complete sample of the fix. 

Posted on February 3, 2009 15:12
Actions: E-mail | Comments (3)

Comments


henry

henry

February 2, 2009 19:24

treading man
          


henry cheund

henry cheund

February 3, 2009 00:25

tread man
          


Caleb Vear

Caleb Vear

February 11, 2009 06:14

The other thing you could have done is just wrap the content of the expander in an AdornerDecorator.  The border is drawn in the adorner layer, and by default a window only has one adorner layer.  Adding the AdornerDecorator will add a new adorner layer which will have its visibility controlled by the expander.
          


Add comment

Enter your name, handle, alias, or email.

We'll incarnate your avatar from the services below.