事件“ SelectedIndexChanged”在WPF中找不到 [英] Event "SelectedIndexChanged" is not found in wpf
问题描述
在winform中,当我创建一个组合框时,我发现事件 SelectedIndexChanged
该事件起作用在组合框的索引更改后
in winform when i create a combobox i can found event "SelectedIndexChanged" the event work after index of combobox changed
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
MessageBox.Show("after index change app show this MessageBox ");
}
但是在wpf中我找不到事件 SelectedIndexChanged
而不是我可以找到事件 SelectionChanged
,但是在组合框事件工作的索引之前使用它时遇到了问题,但是我想在索引更改后在事件 SelectionChanged中显示我的代码
but in wpf i cannot found event "SelectedIndexChanged" instead of i can found event "SelectionChanged" but i have a problem when is use it before index of combobox event work but i want to after index change show my code in event "SelectionChanged"
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
MessageBox.Show("before index change app show this MessageBox ");
}
我该怎么办。我想在更改组合框的索引后显示我的MessageBox
what should i do . i want to show my MessageBox after i change index of my combobox
为我的英语不好而
推荐答案
实际上,在更改索引和值后将调用事件'SelectionChanged',您可以对其进行简单检查
Actually The event 'SelectionChanged' is called after index and value are changed you can check it simple
public partial class MainWindow : Window
{
private string[] _cmbxSource = new string[] {
"ZeroIndex",
"FirstIndex"
};
public MainWindow()
{
InitializeComponent();
cmbx.ItemsSource = _cmbxSource;
cmbx.SelectionChanged += cmbx_SelectionChanged;
}
void cmbx_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
MessageBox.Show(string.Format("Value and Index has been changed {0} {1}",
_cmbxSource[cmbx.SelectedIndex], cmbx.SelectedIndex));
}
}
这篇关于事件“ SelectedIndexChanged”在WPF中找不到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!