4
我有一個主 - 細節場景,其中有一個ComboBox列出來自ObjectDataSourceProvider的公司。在那之下,我有兩個組合框綁定到當前公司對象的聯繫人屬性。我需要能夠在每個ComboBox中選擇不同的聯繫人;但是,只要我在一個列表中更改了選擇,另一個列表就會更新到同一個聯繫人。數據綁定2個WPF組合框到1個源而不被「鏈接」
我試過不同的設置(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不鏈接?
輝煌,雖然這已經造成了另一個問題,我想我可以與它合作。感謝鮑勃,你似乎是個不錯的WPF大師! – palehorse 2008-09-25 19:53:43