Converter in other multibinding converter - input value is UnSetValue.


  • Please see the xaml code below:
    MultiBinding Converter="{StaticResource twoBooleanAndConverter}" >
    Binding Path="Entity.IsPreDefined" Mode="OneWay" Converter="{StaticResource invertedBooleanConverter}" />
    Binding Path="Entity.IsAdded" Mode="OneWay"/>

    The problem is in twoBooleanAndConverter, the first input value is always UnSetValue. If I don't use inverterBooleanConverter, the input values in twoBooleanAndConverter are correct.
    It's very strange that with the sample code in the beginning, if I bind to ComboBox.IsEnabled property (change
    ComboBox.Style to ComboBox.IsEnabled), it works well - the input values for twoBooleanAndConverter are correct.
    Anyone has idea in this case?
    Thank you very much.

    • Edited by itanium35 Thursday, June 19, 2008 7:51 PM xaml
    Thursday, June 19, 2008 7:50 PM

All replies

  • Could you please provide a small, complete and ready-to-run example to demonstrate the issue you are encountering?



    Tuesday, June 24, 2008 6:56 AM
  • I ran into the same problem, almost with the same setup of booleans, nots and "and"s... weird, how much duplicate code is written around the world.
    The thing is, WPF tries to convert for you each of the inner bindings, into a value of the type requested by the outer binding (the multibinding). Thus, your inner binding, the invertedboolean, is actually expected to return a style. Break in the inverting converter and check the target type. The boolean that it does return, is obviously not a style and therefore it is passed as an unsetvalue to the multibinding. If any1 ever asked for my opinion, I would consider this a bug in WPF.
    My workaround was easy, since I was not asked to return a style, rather a visibilty. My inverter converter translated its boolean value to visibilty, if this was the requested type. In the case of a style -- dunno, maybe just use null and new Style().
    • Proposed as answer by Tor Langlo Wednesday, August 19, 2009 7:42 PM
    Sunday, July 27, 2008 7:55 AM
  • I have come to the same conclusion as dfl. WPF's MultiBinding requires the output value of each inner binding to be of the same type as the output of the outer multi binding. Any output value from the inner binding of a different type will cause the input value passed to the IMultiValueConverter.Convert method's values parameter to be equal to DependencyProperty.UnsetValue.

    It has caused me several ours of troubleshooting to come to this conclusion. The behavior of the MultiBinding in this respect is non-intuitive and is not documented anywhere.


    Tor Langlo, Koda Software
    • Proposed as answer by schmiddy98 Wednesday, January 12, 2011 12:51 AM
    Wednesday, August 19, 2009 7:47 PM
  • I tried out Tor's theory with an instance I had.  With a MultiBinding that had a child binding like itanium35 's set on a Visibility property it looks like it returns UnsetValue for that binding.  When I changed the property to IsEnabled, the MultiBinding worked as expected.


    Thanks, Tor.

    Wednesday, January 12, 2011 12:57 AM