WPF Run Inheritance

I would like to use a trigger trigger, but I need to select the ancestor property, for example:

<Trigger Property="State" Value="Expanded"> <Setter Property="Background" Value="Red" /> </Trigger> 

Only that the property of the state should be the property of an unknown ancestor of a known type and if it could not be found, then the trigger will never be executed.

So my question is: how can I find the ancestor to get the property to use in the trigger?

I hope I get it. Thank you in advance.

+4
source share
1 answer
 <DataTrigger Binding="{Binding State, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Whatever}}}" Value="Expanded"> 
+4
source

All Articles