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