バインディングが null の場合 (PriorityBinding のようにバインディングが無効な場合ではなく)、優先度の低いバインディングが使用されることを除いて、PriorityBinding と同様のことを行う必要があります。使用したいバインディングごとに 1 つずつ 2 つの重複コントロールを作成し、バインディングが null であるかどうかに基づいてそれらの可視性をトリガーする以外に、これを行うための「良い」方法を理解できないようです。何かを変更する必要があるたびに2つのコントロールを更新したくないので、より良い方法があるはずです(重複コード==悪い)。
例:
SelectedItem.SelectedItem が null でない場合:
<ContentControl Content="{Binding SelectedItem.SelectedItem}"/>
SelectedItem.SelectedItem が null の場合:
<ContentControl Content="{Binding SelectedItem}"/>
このようなスタイルを使用してもうまくいきませんでした:
<ContentControl Content="{Binding SelectedItem.SelectedItem}">
<ContentControl.Style>
<Style TargetType="ContentControl">
<Style.Triggers>
<DataTrigger Binding="{Binding SelectedItem.SelectedItem}" Value="{x:Null}">
<Setter Property="Content" Value="{Binding SelectedItem}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</ContentControl.Style>
</ContentControl>
スタイルのバインディングが ContentControl の Content プロパティをソースとして使用しようとしているため、DataTrigger が実際にテストしているため、これは機能しなかったと思いますSelectedItem.SelectedItem.SelectedItem.SelectedItem
。何か案は?