R – Getting a reference to the ViewModel from an IValueConverter


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.

Best Solution

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.