I have a ComboBox with a list of names of objects. When I perform my rename command, the selected item's name changes in the list of items but will not show the updated name at the top unless I click to a different object then back. Here is a picture of the problem:
Here is my ComboBox xaml:
<ComboBox Name="CSCB" IsEditable="True" IsReadOnly="True" Margin="8"
ItemsSource="{Binding Systems, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
DisplayMemberPath="Name"
SelectedItem="{Binding SelectedCoord, Mode=TwoWay}"
Text="Select a Coordinate System"
/>
Let me know if I should include more code. Thank you :)
答案 0 :(得分:0)
不幸的是,您必须重新实现这样做的自定义combobox
,或者您只需在combobox
事件上手动刷新TextChanged
项,如下所示:
private void TextBoxBase_OnTextChanged(object sender, TextChangedEventArgs e)
{
CSCB.Items.Refresh();
}
假设你的xaml看起来像那样:
<StackPanel>
<ComboBox Name="CSCB" IsEditable="True" IsReadOnly="True" Margin="8"
ItemsSource="{Binding Systems, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
DisplayMemberPath="Name"
SelectedItem="{Binding SelectedCoord, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
Text="Select a Coordinate System"
/>
<TextBox Text="{Binding SelectedCoord.Name,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" TextChanged="TextBoxBase_OnTextChanged"></TextBox>
</StackPanel>