【发布时间】:2020-05-05 19:52:47
【问题描述】:
我的数据网格 ClassificationComboBox 和 DisclosureNoteComboBox 中有 2 个 DataGridComboBoxColumn。 第一个工作正常,我看到它填充了数据。 我想要的是,当在第一个项目中选择一个项目时,即 ClassificationComboBox ,我希望第二个项目显示第一个项目中所选项目的数据列表。 ClassificationComboBox 中选定的项目是分类类型,它有一个名为 ClassificationRecords 的列表,我希望将其填充到 DisclosureNoteComboBox 中。
这是我的 XML 的 sn-p。
<materialDesign:DataGridComboBoxColumn Header="Classification" IsEditable="False" x:Name="ClassificationComboBox"
ItemsSourceBinding="{Binding ElementName=TrialBalanceViewName, Path=Report.Classifications}"
DisplayMemberPath="Name"
SelectedValuePath="Id"
SelectedValueBinding="{Binding ClassificationRecord.ClassificationId}"
/>
<materialDesign:DataGridComboBoxColumn Header="Disclosure Note" IsEditable="False" x:Name="DisclosureNoteComboBox"
ItemsSourceBinding="{Binding ElementName=ClassificationComboBox, Path=SelectedValueBinding.ClassificationRecords}"
SelectedValuePath="DisclosureNote"
SelectedValueBinding="{Binding ClassificationRecord.DisclosureNote}"
/>
我怀疑我的问题是如何为第二个(尤其是路径)构造 ItemsSourceBinding。我认为这是错误的,但我不确定如何调用第一个的选定项目并在其上调用 ClassificationRecords 作为第二个的 ItemSource
ItemsSourceBinding="{Binding ElementName=ClassificationComboBox, Path=SelectedValueBinding.ClassificationRecords}"
【问题讨论】:
标签: c# wpf data-binding datagrid datagridcomboboxcolumn