質問

私はテキストブロックを持っています。そのテキストがバインドされている場合:

<Binding Path="Applicant2.Surname"/>

正常に動作しますが、前提を含めたいので、バインディングを変更しました。

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

これは、値が初めて設定されるまで{DependencyProperty.UnsetValue} {DependencyProperty.UnsetValue}を表示します。

どうすればこれを止めることができますか?最初の単純なバインディングで問題が発生しないのはなぜですか?

役に立ちましたか?

解決

マルチバインディングの場合、フォールバック値を追加する必要があります。

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

他のヒント

マルチバインディングのために、私は以下のコードを使用し、私のために働きました:

<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>

以下はそれの特性です:

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));
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top