Have you tried any of the following (extracted from Adam Nathan's book: Windows Presentation Foundation Unleashed):
- Multiple triggers apply to the same element (to get a logical OR).
- Several properties evaluated for the same trigger (to obtain a logical AND).
Logical OR
Since Style.Triggers can contain multiple triggers, you can create more than one with the same Setters to express the logical relation OR.
For example:
<Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> ... </Trigger> <Trigger Property="IsKeyboardFocusWithin" Value="True"> .... </Trigger> </Style.Triggers>
This means that "if IsMouseOver is true, or if the value of IsKeyboardFocusWithin is true, apply the action.
Logical and
To express the logical AND relation, you can use the Trigger variant called MultiTrigger , or the DataTrigger variant called MultiDataTrigger . Both triggers have a set of Conditions that contain information that you usually put directly in a trigger or DataTrigger.
For example:
<Style.Triggers> <MultiTrigger> <MultiTrigger.Conditions> <Condition Property="IsMouseOver" Value="True"/> <Condition Property="IsKeyboardFocusWithin" Value="True"/> </MultiTrigger.Conditions> </MultiTrigger> <Setter ...> <Setter ...> </Style.Triggers>
Adel hazzah
source share