5

ObjectDataSourceProviderから1つのComboBoxリスト会社があるマスター/詳細シナリオがあります。その下に、現在のCompanyオブジェクトからContactsプロパティにバインドする2つのComboBoxがあります。各ComboBoxで異なる連絡先を選択できるようにする必要があります。ただし、一方のリストの選択を変更するとすぐに、もう一方のリストが同じ連絡先に更新されます。

さまざまな設定(OneWayとTwoWay)を試しましたが、これまでのところ何も機能していないようです。これが私のXAMLの抜粋です。

<Page.Resources>
    <!-- This is a custom class inheriting from ObjectDataProvider -->
    <wg:CustomersDataProvider x:Key="CompanyDataList" />
</Page.Resources>

<Grid>
    <!--- other layout XAML removed -->
    <ComboBox x:Name="Customer" Width="150"
              ItemsSource="{Binding Source={StaticResource CompanyDataList},Path=Companies,Mode=OneWay}"
              DisplayMemberPath="Name"
              SelectedValuePath="Id"
              IsSynchronizedWithCurrentItem="True"
              SelectedValue="{Binding Path=Id, Mode=OneWay}" 
              VerticalAlignment="Bottom" />

    <ComboBox x:Name="PrimaryContact" Width="150"
              DataContext="{Binding ElementName=Customer,Path=Items,Mode=OneWay}"
              ItemsSource="{Binding Path=Contacts,Mode=OneWay}"
              DisplayMemberPath="FullName"
              SelectedValuePath="Id"
              IsSynchronizedWithCurrentItem="True"
              SelectedValue="{Binding Path=Id,Mode=OneWay}" />

    <ComboBox x:Name="AdminContact" Width="150"
              DataContext="{Binding ElementName=OwnerCustomer,Path=Items,Mode=OneWay}"
              ItemsSource="{Binding Path=Contacts,Mode=OneWay}"
              DisplayMemberPath="FullName"
              SelectedValuePath="Id"
              IsSynchronizedWithCurrentItem="True"
              SelectedValue="{Binding Path=Id,Mode=OneWay}" />

    <!--- other layout XAML removed -->
</Grid>

CollectionViewSourceを作成するのが道だと思いましたが、それを機能させることができませんでした。PrimaryContactとAdminContactがリンクされないようにする簡単な方法はありますか?

4

1 に答える 1

4

「 IsSynchronizedWithCurrentItem」属性を「False」に変更します。

于 2008-09-25T18:25:25.973 に答える