O'Reilly logo

XAML Unleashed by Adam Nathan

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

Whereas data templates can customize the way data is rendered, value converters can morph each piece of data before it reaches the target. They enable you to plug in custom logic without giving up the benefits of data binding.

Value converters are sometimes used to reconcile a source and target that are different data types. For example, you could change the background or foreground color of an element based on the value of some non-Brush data source, à la conditional formatting in Microsoft Excel. Or you could use it to enhance the information displayed, without the need for separate elements.

Imagine that we want to set the Header of the photo-filled GridView so it displays the number of photos. We could bind the Header ...

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