1

私のメイン ウィンドウ xaml には、2 つのユーザー コントロールと 2 つRadioButtonの があります。RadioButtonsVisibilityでユーザー コントロールの を制御したい。
xaml の抜粋:

    <WpfApp2:ViewTree/>

    <WpfApp2:ViewTab/>

    <RadioButton x:Name="radioButton_Tree" GroupName="View"
                 IsChecked="True"> Tree View </RadioButton>

    <RadioButton x:Name="radioButton_Tab" GroupName="View"
                 IsChecked="False" >Tab View</RadioButton>

ユーザーコントロールには、次のようなものがあります。

Visibility="{Binding IsChecked, 
                     Converter={StaticResource BooleanToVisibilityConverter}, 
                     ElementName=Window1.radioButton_Tree}" >

実行時に次のエラーが発生します。
Cannot find source for binding with reference 'ElementName=Window1.radioButton_Tab'

私は何を見落としていますか?

4

1 に答える 1

1

Window1 という名前は、ユーザー コントロールのコンテキストにはありません。

以下のコードを使用できますか?

<WpfApp2:ViewTree Visibility="{Binding IsChecked, 
                  Converter={StaticResource BooleanToVisibilityConverter}, 
                  ElementName=radioButton_Tree}" />

<WpfApp2:ViewTab Visibility="{Binding IsChecked, 
                 Converter={StaticResource BooleanToVisibilityConverter}, 
                 ElementName=radioButton_Tab}" />

<RadioButton x:Name="radioButton_Tree" GroupName="View"
             IsChecked="True"> Tree View </RadioButton>

<RadioButton x:Name="radioButton_Tab" GroupName="View"
             IsChecked="False" >Tab View</RadioButton>
于 2009-09-11T17:33:56.270 に答える