WPF Listview SelectionChanged event

前端 未结 5 1605
滥情空心
滥情空心 2021-02-05 17:04

I have a ListView binding to an ItemsSource and the SelectionChanged event is firing on the load/databound events? I assume that it is bec

5条回答
  •  忘掉有多难
    2021-02-05 17:26

    I don't know if you still need help with this, but I solved this problem by making a variable that tracks the selectedindex, in my case -- when initially bound it's always 0 so it's a little easier for me to do, however if you inform the viewmodel of the appropriate index, I simply added a

    ComboBox box = e.OriginalSource as ComboBox;
    if (_previousIndex == cb.SelectedIndex) return;
    //do stuff you need to do with a new SelectedIndex
    

提交回复
热议问题