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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access