c# - How to capture RightMouse Click in empty area of tab control? -


i have normal c# tab control. want execute function when user right-clicks in empty area right of right-most tab header (anywhere in tab header area that's not tab ok too).

i looked @ positioning hidden button in empty area, doesn't fill space , hard-coded approach.

i looked @ creating hidden tab in empty area, won't fill empty space , required header width dependent on how many other tabs showing; in addition, users might accidentally click on , navigate away current tab, not because things happen automatically on tab changes.

is there elegant way capture right-click in empty area?

i ended doing setting style event handler so:

<style x:key="{dxt:dxtabcontrolinternalthemekey resourcekey=panelcontainertoplayoutstyle, isthemeindependent=true}" targettype="{x:type dx:tabpanelcontainer}" basedon="{staticresource {dxt:dxtabcontrolinternalthemekey resourcekey=panelcontainertoplayoutstyle}}">         <eventsetter event="previewmouserightbuttondown" handler="dxtabcontrol_previewmouserightbuttondown"/>         <setter property="background" value="transparent"/>     </style> 

then looked in event handler see if there parent object this:

    private void tabcontrol_previewmouserightbuttondown(object sender, mousebuttoneventargs e) {         dxtabitem parentobject = devexpress.xpf.core.native.layouthelper.findparentobject<dxtabitem>(e.originalsource dependencyobject);          // if click happened on empty area (i.e., no parent object found), toggle admin button         if (parentobject == null) {             if (tabitem_admin.visibility == system.windows.visibility.visible)                 tabitem_admin.visibility = system.windows.visibility.collapsed;             else                 tabitem_admin.visibility = system.windows.visibility.visible;         }     } 

this solution uses devexpress libraries , courtesy of excellent devexpress support team!


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -