AdornedElement Properties in a Trigger

Posted by Chris Nicol on Stack Overflow See other posts from Stack Overflow or by Chris Nicol
Published on 2010-05-31T21:32:28Z Indexed on 2010/06/02 23:34 UTC
Read the original article Hit count: 369

Filed under:
|
|
|

I have an Adorner in XAML that I'm using for ErrorValidation. Basically I have a grid that I want to display on two conditions (if the "AdornedElement" IsFocused or IsMouseOver).

Below is a code snippet where I'm binding - successfully - to the IsFocused of the AdornedElement, but as you can tell that only solves 1/2 the conditions. Now I can't pass another binding into the converter, nor can I create a property that handles both (needs to be XAML only solution).

 <AdornedElementPlaceholder
                            x:Name="errorAdorner" />
                    ...

  <Grid
     x:Name="ErrorDetails"
     Visibility="{Binding ElementName=errorAdorner, Path=AdornedElement.IsFocused, Converter={StaticResource BooleanToVisibilityConverter}}" />

                   ...

What I want to do is use triggers to handle this, the only problem is I can't access the AdornedElement's properties on a trigger.

Something like this ...

        <Trigger
            SourceName="errorAdorner"
            Property="AdornedElement.IsFocused"
            Value="True">
            <Setter
                TargetName="ErrorDetails"
                Property="Visibility"
                Value="Visible" />
        </Trigger>

This would also help as part of what I want to do is trigger animations, rather than just setting the visibility.

Any help would be great.

© Stack Overflow or respective owner

Related posts about wpf

Related posts about binding