Canceling tab selection
WPF
1
Posts
1
Posters
1
Views
1
Watching
-
Hi, does anybody knows what is the WPF way to avoid Tab Selection? in WinForms i had the Selecting event which i could cancel (with CancelEventArgs) i need to cancel (or not) based on the tab which i"m exiting (the previous tab). i get all that information in SelectionChanged but that's too late to cancel. i can't use MouseClick because i don't have all the information i need. all i've managed is the following (ugly) code in SelectionChanged:
if (!m\_InSelectionChanged && e.Source == e.OriginalSource) { m\_InSelectionChanged = true; if (e.RemovedItems.Count > 0) { TabItem unselecetd = e.RemovedItems\[0\] as TabItem; TabItem selected = e.AddedItems\[0\] as TabItem; if (selected != null && unselecetd != null) { CancelEventArgs args = new CancelEventArgs(); Check(args); if (!args.Cancel) { // Logic } else { // Re select what was previously selected m\_TabControl.SelectedItem = unselecetd; } } } m\_InSelectionChanged = false; }
any other ideas? no way that it can't be done in wpf with some technique yanai