I wanted to add a contextmenu to a tabitem. But it should only be opened by clicking on the header of the tab. I added the Contextmenu like this:
ContextMenu _contextMenu;
TabItem _tabItem;
//Initialize the components
_tabItem.ContextMenu = _contextMenu;
Only if you klick on the header of the TabItem, the ContextMenu should be opened.
But if you klick at another position of the tabItem, it shouldn´t be displayed.
I need to do that programmatically during the runtime. A solution in xaml is ok, too.
How about something like:
_tabItem.Header = new ContentControl
{
Content = "StartPage",
ContextMenu = _contextMenu
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With