MultiConverterGroup and MapConverter

Dec 3, 2008 at 9:34 PM

I have just found out today about this great library while in the middle of the process of rolling out my own similar thing. I immediately dropped all efforts and focused on a plethora of features this lib already offers.

While playing I wanted to solve my own simple-real-world-problem and I failed miserably. Thus I am now seeking help here.

I have two dependency properties that need to affect some Visibility property. Two properties are ints and the condition is something along the lines of X + 3 > Y. It looks like using a MultiBinding, ExpressionConverter and a MapConverter is the way to go but I keep failing in finding a proper way to do it. In order to do anything with TWO (or more) input properties one must use MultiBinding and thus MultiConverterGroup. An ExpressionConverter seems happy in a MultiConverterGroup but MapConverter (implementing just IValueConverter) is not happy. Basically I just want to translate boolean to Visibility.

Can somebody please point me in the right direction? Thanks!
Dec 3, 2008 at 9:37 PM
Just another thought... Shouldn't MapConverter also implement IMultiValueConverter so it could participate in a MultiConverterGroup?
Jun 8, 2011 at 9:45 AM

I ran into the same issue.

The problem is that, although ConverterGroup will chain a series of IValueConverters, and MultiConverterGroup will chain a series of IMultiValueConverters together, there doesn't seem to be any way of chaining a series of IMultiValueConverters into an IValueConverter.

I finally used a workaround of a MultiBinding with my IMultiValueConverters into a Tag property and then binding my real target to the Tag using an IValueConverter.

I think MultiConverterGroup should have a Converter property which takes an IValueConverter and applies this to it's result before returning.

You could even then populate this property with a ConverterGroup and get another chain going!

In fact I think I will raise this through the issue tracker.

Sep 5, 2011 at 12:39 PM

V1.1.0.0 supports the ternary conditional operator, which should alleviate this issue. For example, you could use an expression of:

{0} + 3 > {1} ? {2} : {3}

and then substitute in values for x, y and the desired Visibility values.