views:

26

answers:

1

Hello.

I am using a DataTemplate (a StaticResource) in several places in my application as in an ItemsControl, ContentControl and in a ToolTip.

The template contains an Expander, and I want its IsExpanded property to be true if the DataTemplate is located within a ToolTip.

Any recommendations?

A: 

This checks for the parent tooltip, if there is no parent tooltip, it will be evaluated to nothing = false:

<Expander Name="expJobContacts" 
    IsExpanded="{Binding IsVisible, 
        RelativeSource={RelativeSource Mode=FindAncestor, 
            AncestorType={x:Type ToolTip}}, 
        Mode=OneTime}" />

I tested and it works.

Shimmy