Do not allow unselect/deselect in ListBox

后端 未结 2 1057
滥情空心
滥情空心 2020-12-11 22:11

Is there a way to configure the WPF ListBox such that it\'s not possible to deselect/unselect an item? So there is always an item selected?

My Lis

2条回答
  •  误落风尘
    2020-12-11 22:44

    You can handle the SelectionChanged event and set a selection if the SelectedItem evaluates to null. To reselect an item that has been unselected you can keep track of the last selected item in a private field, which should always be updated in the SelectionChanged event.

提交回复
热议问题