Is there a way to prevent Selection change in RadListBox?

Dmitry

I am trying to use RadListBox and I have a scenario when I need to prevent selection change in list box (for example user wants to save change he/she made before navigating away from currently selected item). How can I accomplish this?

Kalin

If I understand you correctly you need to prevent the selection while the saving process is running. What I can suggest you would be to simply set the IsEnabled property of the ListBox to false while saving and set it true again when saved.

Hope this helps. However if this is not the exact case I'll ask you to share more detailed information about the exact scenario.

Regards,
Kalin
Telerik

Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.

Dmitry

No, this is not the exact scenario. It looks like this: ListBox is used to show collection of items, while user selects any of the item he/she can get detailed view of the item in other part of the user control, and user can edit item properties. But if user edited item and did not save changes, and tries to select another item I want to show a confirmation window "Save changes?" with buttons Yes/No/Cancel.
In case of yes/no, I just save or dismiss user's changes and Selection in list box can be changed, but if User clicks Cancel button - I need to prevent selection change in ListBox.
Is there a way to do this using RadListBox, or I should use some other control for such a scenario?

Kalin

Thanks for the further details. What I can suggest you in order to achieve the desired scenario would be to attach MouseButtonDown class handler to all of the ListBoxItems. This way you will be able to "preview" the SelectionChanged, display the confirmation dialog and if you doesn't want to change the SelectedItem you can simply handle the MouseButtonDown event and this will prevent the selection. Please check the following code snippet:

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.