开发者

WPF MultiBinding - UnsetValue Issue

I have a TextBlock. When its Text is bound as:

<Binding Path="Applicant2.Surname"/>开发者_如何学Go;

It works fine, however I want to include the Forenames so changed the binding to:

<MultiBinding StringFormat="{}{0} {1}">
    <Binding Path="Applicant2.Forenames"/>
    <Binding Path="Applicant2.Surname"/>
</MultiBinding>

This displays {DependencyProperty.UnsetValue} {DependencyProperty.UnsetValue} until the value is set the first time.

How can I stop this? Why do I not get the problem with the first simple binding?


for a multibinding you need to add a fallback value if it is just blank then you can simply do:

<MultiBinding StringFormat="{}{0} {1}">
    <Binding Path="Applicant2.Forenames" FallbackValue=""/>
    <Binding Path="Applicant2.Surname" FallbackValue=""/>
</MultiBinding>


For multibinding, I used below code and worked for me :

<MultiBinding Converter="{StaticResource ValueToAngle}" StringFormat="{}{0} {1}">
                        <MultiBinding.Bindings>
                            <Binding RelativeSource="{RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}" Path="TotalSkidCount"/>
                            <Binding RelativeSource="{RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}" Path="ActualCount"/>
                        </MultiBinding.Bindings>
                    </MultiBinding>

Below is the property of it :

public int ActualCount { get { return (int)GetValue(ActualCountProperty); } set { SetValue(ActualCountProperty, value); } }
public static readonly DependencyProperty ActualCountProperty = DependencyProperty.Register("ActualCount", typeof(int), typeof(CirculerProgressBarControl));

public int TotalSkidCount { get { return (int)GetValue(TotalSkidCountProperty); } set { SetValue(TotalSkidCountProperty, value); } }
public static readonly DependencyProperty TotalSkidCountProperty = DependencyProperty.Register("TotalSkidCount", typeof(int), typeof(CirculerProgressBarControl));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜