wpf - Is there a way to cancel TabControl.Items.CurrentChanging? -


there unfortunately no tabcontrol.selectionchanging event (selector.selectionchanging), struggling implement behavior can cancel changing request.

i tried handle tabcontrol.items.currentchanging (the items property , itemcollection) event setting e.cancel (of currentchangingeventargs) true, ui is updated new tab although item not changed in collection.

is there way prevent user switching different tabitem when condition dissatisfied?

i don't know exact reason why happens, , annoys me greatly.

but here's workaround it:

in sample below, checkbox "locking" current tab. checked means user can't change tab.

void items_currentchanging(object sender, currentchangingeventargs e) {     if (checkbox1.ischecked.value)     {         var item = ((icollectionview)sender).currentitem;          e.cancel = true;          tabcontrol1.selecteditem = item;     } } 

basically, happens (if understand correctly) visual tree gets updated, logical tree not. above way forces visual sync logical tree.


Comments

Popular posts from this blog

SAP Web Service from .NET via WCF -

Optimized Line drawing in QT -

datetime - str to time in python -