views:

337

answers:

1

Is there a clean and/or an accepted standard way of referring back to the ViewModel from an IValueConverter, or does that break the MVVM pattern? Basically, I want to convert bound data in the UI based on other properties of the ViewModel. I guess this is the same question as how do you refer back to the Window/Page from an IValueConverter since a reference to the control is not passed to the Convert/ConvertBack methods.

+2  A: 

I would suggest adding a new property to the ViewModel that concatenates or combines the other properties in the ViewModel. This eliminates the need for an IValueConverter all together.

Check out this discussion on IValueConverters when using MVVM.

Josh G
+1 Converters can be largely be abolished when practicing MVVM. You'll get cleaner, more comprehensible code as a result.
Kent Boogaart