O'Reilly logo

Windows Presentation Foundation 4.5 Cookbook by Pavel Yosifovich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Binding to multiple properties

So far we've seen data binding occur for a target property base on a single source property. Sometimes, however, a target property depends on changes of more than one source property. This is supported in WPF through multi binding. Let's see how it's done.

Getting ready

Make sure Visual Studio is up and running.

How to do it...

We'll create a simple color selector using a multi-binding.

  1. Create a new WPF application named CH06.MultiBindings.
  2. Open MainWindow.xaml. Add the following to the existing Grid:
    <Grid.RowDefinitions> <RowDefinition /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Rectangle Stroke="Black" StrokeThickness="1" Margin="4" > </Rectangle> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required