0
有组合框绑定的Observable集合。当更新selecteditem时,WPF组合框selectedvalue不更新
public ObservableCollection<AnyType> AnyTemplates { get; set; }
和ComboBox结合到此集合:
<ComboBox Name="cmbKeyA"
Width="100"
SelectedValue="{Binding Path=KeyAName}"
ItemsSource="{Binding Path=DataContext.KeyTemplates, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
DisplayMemberPath="Name"
SelectedValuePath="Name"/>
首先集合为空。然后,当我在收藏中添加新值时,checkBox selectedItem更改为此值。如果我更改集合Item中的Name属性,则会更改组合框selectedItem(我会看到DisplayMemberPath更改为新值),但选中的值不会更改,直到我手动再次选择此项目。 Name属性集合元素调用PropertyChanged事件。 为什么这不起作用。总结:当我在comboxo SelectedItem程序中更改NameProperty时,组合框SelectedItem被更改,但是SelectedValue没有更新,直到我手动再次在组合框中更改组合框。