开发者

Wpf - Contextmenu in TabItem Header

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;
/开发者_StackOverflow社区/Initialize the components
_tabItem.ContextMenu = _contextMenu;

Only if you klick on the header of the TabItem, the ContextMenu should be opened.

Wpf - Contextmenu in TabItem Header

But if you klick at another position of the tabItem, it shouldn´t be displayed.

Wpf - Contextmenu in TabItem Header

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
                 };
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜