5

我有一个主从场景,其中我有 1 个 ComboBox 列出来自 ObjectDataSourceProvider 的公司。在此之下,我有 2 个 ComboBoxes 绑定到当前 Company 对象的 Contacts 属性。我需要能够在每个 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 回答