2011-08-11 12 views
5

私は、タブアイテムにコンテキストメニューを追加したいと思っていました。タブのヘッダーをクリックすることによってのみ開くことができます。 私はこのようなコンテキストメニューを追加しました:あなたはのTabItemのヘッダーにklickWpf - TabItemヘッダーのコンテキストメニュー

ContextMenu _contextMenu; 
TabItem _tabItem; 
//Initialize the components 
_tabItem.ContextMenu = _contextMenu; 

場合のみ、のContextMenuを開くべきです。あなたがのTabItemの別の位置にklick場合

It should only work by right-klicking in the header

しかし、それはshouldn't表示すること。

If you don´t klick on the header, it shouldn´t displayed

私は、実行時にプログラム的にそれを行う必要があります。 xamlの解決策もOKです。

答えて

7

どのようなものについて:

_tabItem.Header = new ContentControl 
       { 
        Content = "StartPage", 
        ContextMenu = _contextMenu 
       }; 
+0

おかげで、完璧に動作します。 –

関連する問題