【发布时间】:2013-06-21 21:31:19
【问题描述】:
我正在尝试通过以下方式实现主从关系:
(shown in a ComboBox) (shown in a DataGrid)
|-----------| |------------|
| Customers | | Orders |
|-----------| |------------|
| Id |--- CustomersOrdersRelation ---| CustomerId |
| Name | | OrderId |
| ... | | ... |
|-----------| |------------|
但我在组合框中还有一个
这是 XAML 代码的 sn-p:
<ComboBox x:Name="CustomersComboBox" ...>
<ComboBox.ItemsSource>
<CompositeCollection>
<ComboBoxItem Content="{StaticResource nullCustomer}" /> <!-- I wrote my own class NullCustomer -->
<CollectionContainer Collection="{Binding Source={StaticResource CustomersCollectionViewSource}}" />
</CompositeCollection>
</ComboBox.ItemsSource>
</ComboBox>
<DataGrid ItemsSource="{Binding ElementName=CustomersComboBox, Path=SelectedItem.CustomersOrdersRelation}" ...>
现在我有两个问题:
当组合框的
SelectedItem(它是运行时的DataRowView)没有属性CustomersOrdersRelation时,数据网格中的绑定如何找到Path=SelectedItem.CustomersOrdersRelation?修改我自己的
NullCustomer类以便在我选择 时显示AllOrdersCollectionViewSource的结果的最简单方法是什么?
【问题讨论】:
标签: wpf data-binding binding master-detail