How does FallbackValue work with a MultiBiding?

Posted by Will on Stack Overflow See other posts from Stack Overflow or by Will
Published on 2010-04-19T16:11:45Z Indexed on 2010/04/19 16:13 UTC
Read the original article Hit count: 503

Filed under:
|
|

I ask because it doesn't seem to work.

Assume we're binding to the following object:

public class HurrDurr
{
  public string Hurr {get{return null;}}
  public string Durr {get{return null;}}
}

Well, it would appear that if we used a MultiBinding against this the fallback value would be shown, right?

<TextBlock>
    <TextBlock.Text>                                
        <MultiBinding StringFormat="{}{0} to the {1}"
                        FallbackValue="Not set!  It works as expected!)">
            <Binding Path="Hurr"/>
            <Binding Path="Durr"/>
        </MultiBinding>
    </TextBlock.Text>
</TextBlock>

However the result is, in fact, " to the ". Even forcing the bindings to return DependencyProperty.UnsetValue doesn't work:

<TextBlock xmnlns:base="clr-namespace:System.Windows;assembly=WindowsBase">
    <TextBlock.Text>                                
        <MultiBinding StringFormat="{}{0} to the {1}"
            FallbackValue="Not set!  It works as expected!)">
            <Binding Path="Hurr"
                FallbackValue="{x:Static base:DependencyProperty.UnsetValue}" />
            <Binding Path="Durr"
                FallbackValue="{x:Static base:DependencyProperty.UnsetValue}" />
        </MultiBinding>
    </TextBlock.Text>
</TextBlock>

Tried the same with TargetNullValue, which was also a bust all the way around.

So it appears that MultiBinding will never ever use FallbackValue. Is this true, or am I missing something?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about multibinding