Download e-book for iPad: Pro WPF and Silverlight MVVM: Effective Application by Gary Hall

As Listing 2–27 shows, we can omit some elements and the parser will proceed happily with creating an object graph that is synonymous with this layout.

IMultiValueConverter Interface The IMultiValueConverter is very similar to its single-valued sibling, with a couple of obvious differences: object Convert(object[] values, Type targetType, object parameter, CultureInfo culture); object[] CovertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture); With the Convert method, we have pluralized the value parameter, taking an array of objects instead of a single one. This is because we have a number of source values but we are still outputting to one single target value.

Currencies are a prime example of this, and have myriad variations depending on locale. The euro, for instance, is represented with at least three different notations. Visiblity value. We will only implement converting the Boolean value to a Visibility, and not the ConvertBack scenario. Thus, for both brevity and clarity, this value converter will be applicable solely to one-way (readonly) bindings. An extra feature of this converter will be the ability to specify, as the ConverterParameter, what value to use when “false” is encountered on the binding source.

Download PDF sample

Pro WPF and Silverlight MVVM: Effective Application Development with Model-View-ViewModel by Gary Hall


by Kenneth
4.3

Rated 4.46 of 5 – based on 21 votes