Creating a multi trigger

An active trigger can execute actions, but sometimes a trigger needs to be composed of multiple conditions that activate the entire trigger if all conditions are met. This is exactly what the MultiTrigger and MultiDataTrigger types are capable of. Let's see how to create a MultiTrigger.

Getting ready

Make sure Visual Studio is up and running.

How to do it...

We'll create a simple application that changes the way a button appears by using multiple properties set up inside a MultiTrigger:

  1. Create a new WPF application named CH08.MultiTriggerDemo.
  2. Open MainWindow.xaml. Replace the existing Grid with a StackPanel.
  3. Add the following controls inside the StackPanel:
    <Button Content="Move mouse over me" FontSize="20" HorizontalAlignment="Center" ...

Get Windows Presentation Foundation 4.5 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.