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

Using value converters

Data templates provide a powerful way to visualize any data. We discussed a few ways to customize the appearance of data templates. In this recipe, we'll look at value converters, which is a flexible mechanism to customize data bindings in general, and data templates in particular. Their power ranges from simple data transformations to significant visual changes.

Getting ready

Make sure Visual Studio is up and running.

How to do it...

We'll create a weather forecast application that uses a value converter to convert a general weather outlook into a brush.

  1. Create a new WPF application named CH06.WeatherForecast.
  2. We'll create a simple weather forecasting application. Add a new class named Forecast with some simple properties: ...

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