0
给定数据结构 集合元素; String LocationName; }RelativeSource绑定到ComboBox的一个父属性SelectedItem返回对象
而一个绑定到DisplayMemberPath设置为LocationName的这些项目集合(在结构中描述)的ComboBox,如何将DataGrid绑定到XAML中所述组合框的SelectedItem.Elements?
按照我的理解,组合框的SelectedItem属性将返回LocationName。我需要在结构的数据上下文中向上移动,然后将SourceItems附加到Elements。正确?不过,我似乎无法使它与绑定标记一起工作。
P.S.我正在使用示例数据来安装GUI。
谢谢。
更新1:代码如下:
<ComboBox x:Name="ComboBox1"
ItemsSource="{Binding AdSources, Mode=OneWay}"
DisplayMemberPath="NameProperty" />
<ComboBox x:Name="ComboBox2"
ItemsSource="{Binding SelectedItem.CollectionProperty, ElementName=ComboBox1, Mode=OneWay}"
DisplayMemberPath="NameProperty2" />
<data:DataGrid x:Name="DataGrid"
ItemsSource="{Binding SelectedItem.CollectionProperty, ElementName=ComboBox2, Mode=OneWay}">
<data:DataGrid.Columns>
<data:DataGridTextColumn Header="Column1" Binding="{Binding Property1}"/>
</data:DataGrid.Columns>
</data:DataGrid>