我正在尝试从xml文件填充两个组合框。第二个组合框使用第一个组合框值来获取值。
<ComboBox x:Name="cbxUnit"
ItemsSource="{Binding Mode=TwoWay,Source={StaticResource UnitTemplateXML},XPath=/Units/Unit}"
DisplayMemberPath="@Name"
SelectedIndex="{Binding SelectedUnitIndex,Mode=TwoWay}">
</ComboBox>
<ComboBox
DataContext="{Binding ElementName=cbxUnit,Path=SelectedItem}"
ItemsSource="{Binding Mode=OneTime,XPath=./Template/Name}"
SelectedIndex="{Binding SelectedTemplateIndex,Mode=TwoWay}">
</ComboBox>
它们正在填充,但是当我使用DataContext时,第二个组合框SelectedIndex不起作用。 有什么想法可以解决这个问题吗?