Multi-bindings
Multi-binding is a powerful feature in XAML data binding that allows you to bind a single target property to multiple source properties and then apply logic to produce one single value. This technique is particularly useful when a target property’s value depends on more than one source property. The simplest example of this is using StringFormat
.
Multi-binding StringFormat
A typical multi-binding scenario is where you would like to display multiple values in one label. We could, of course, create a property on the ViewModel that concatenates those values, or we could define this as a Multi-binding with StringFormat
.
As an example, we want to show the author of the recipe next to the Last updated timestamp that we already have on our page (Figure 4.9):
Figure 4.9: Showing the author next to the Last updated timestamp
Here’s how it’s done:
- First, let’s add an
Author
property to our ViewModel:public...