Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Triggering by ancestral property

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

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

Only that the State property need to be the property of an unknown ancestor by a known Type and if could not be found then trigger would never execute.

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

Hope I made myself clear. Thank you in advance.

like image 326
Cybered Avatar asked Apr 10 '13 12:04

Cybered


1 Answers

<DataTrigger Binding="{Binding State, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Whatever}}}" Value="Expanded">
like image 57
Kent Boogaart Avatar answered Sep 21 '22 00:09

Kent Boogaart