Event “SelectedIndexChanged” is not found in wpf

后端 未结 1 643
忘掉有多难
忘掉有多难 2021-01-21 15:48

in winform when i create a combobox i can found event \"SelectedIndexChanged\" the event work after index of combobox changed

private void combo         


        
相关标签:
1条回答
  • 2021-01-21 16:17

    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));
        }
    }
    
    0 讨论(0)
提交回复
热议问题