I have a listbox and I want to prevent changing of ListBox's selection if user has not finished certain tasks, this is the best explanation i can provide at this time, in WinForms there used to be selection changing and it has cancellable event arguement, where in we could trap and cancel even of changing the selection.
I thought I will inherit listbox and do something but internally all functionalities in Selector class are hidden that I can see in reflector but there is no way i can inherit and override any methods !!
I derived a class MyListBox from ListBox and added event called SelectionChanging which is cancellable event. Then I used MyListBoxItem as ItemContainer in MyListBox which handles Preview Left Mouse Up event and raises Selection Changing event, on cancel value, I mark event as handled, which prevents new selection as well as it allows me to notify user to do someting.