Creating a multi trigger
It is not mandatory to use a trigger to perform only an action based on a single condition. Sometimes you need to create it with a composition of multiple conditions that activate the entire trigger, if all the conditions are met. This is what the multi trigger does. Let's see how to create a multi trigger.
Getting ready
Open your Visual Studio IDE and create a new WPF application called CH06.MultiTriggerDemo
.
How to do it...
In the following steps, we will build a simple application that will create and execute a multi trigger based on some conditions and change the Foreground
and Background
properties of the TextBox
controls:
- Open the
MainWindow.xaml
file. - Replace the default
Grid
panel with a verticalStackPanel
. - Add two
TextBox
controls inside the panel and set theirText
property to represent some text. Here's the XAML that we will be using in this example:
<StackPanel> <TextBox Text="Focus your cursor here" FontSize="20" HorizontalAlignment...