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 ListBox binds to an ObservableCollection<MyClass>.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can handle the
SelectionChangedevent and set a selection if theSelectedItemevaluates tonull. 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 theSelectionChangedevent.