如何知道组合框弹出窗口中当前选择的项目。因此,当弹出窗口内的导航时,可以更新组合框。
注意:虽然组合框的弹出窗口仍处于打开状态,但需要更新它。如下图所示,
答案 0 :(得分:2)
对于ComboBox,请尝试将IsEditable
设置为True
,如下所示:
<ComboBox IsEditable="True"
IsReadOnly="True"
SelectedIndex="0">
<ComboBoxItem>1</ComboBoxItem>
<ComboBoxItem>2</ComboBoxItem>
<ComboBoxItem>3</ComboBoxItem>
</ComboBox>
答案 1 :(得分:-1)
1)添加选择已更改ComboBox的事件处理程序,如
this.comboBoxName.SelectionChanged += new SelectionChangedEventHandler(comboBoxSelection_NOTHROW);
2)事件处理程序方法实现,
private void comboBoxSelection_NOTHROW(object sender, SelectionChangedEventArgs e)
{
try
{
///Business logic goes here
CUSTOMER selectedItem = (sender as ComboBox).SelectedItem as CUSTOMER;
if (null != selectedUser)
{
comboBoxName.SelectedItem = selectedItem.First();
}
}
}