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 ...

Get XAML Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.