Using multi-value converters
When you want to change the target value based on multiple values of the same or different types, you will need to use multi-binding. This is done by using a multi-value converter (IMultiValueConverter
interface).
In this recipe, we will build a sample demo to learn how to work with multi-binding and multi-value converters.
Getting ready
Open your Visual Studio IDE and create a new project called CH04.MultiValueConverterDemo
, based on the WPF application project template.
How to do it...
Once the project is created, follow these steps to design the UI and do a multi-binding between multiple elements:
- From the
Solution Explorer
, open theMainWindow.xaml
page. - Inside the default
Grid
panel, create a few rows and columns, so that we can position elements at specific cells. Let's divide theGrid
into five rows and three columns:
<Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto...