tab header with custom contextMenu

Docking/MDI for WPF Forum

Posted 11 years ago by Sasha
Version: 13.1.0581


I want to create new tab dynamically in my viewModel with my own contextMenu for header. For this I create textBlock with mouseRightButtonDown event, and add it to documentWindow's header, then I add documentWindow to tabbedMdiContainer and bind it to my view.

Here is my XAMl :

 <docking:TabbedMdiHost Content="{Binding MdiContainer}" IsCloseButtonOnTab="False" x:Name="AlTabbedMdiHost"/>

 and code in viewModel:

var documentWindow = new DocumentWindow ();

var textBlock = new TextBlock { Text = "Text", Height = 15};
textBlock.MouseRightButtonDown += OnTxtBlckRightMouseDown;

documentWindow.Header = textBlock;


 The problem is that the size of a textBlock doesn't fit headers size, so I have two contextMenus - one when I click on a header and another when I click on a textBlock.

How can I solve this problem?

Thnx in advance.

Comments (1)

Answer - Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA

Hi Sasha,

The DocumentWindow is represented by the "tab" inside the UI.  So you could attach to the DocumentWindow's mouse event instead and then see if the click was in the bounds of the DocumentWindow.  If so, you should know it was on the tab.

Actipro Software Support

The latest build of this product (v24.1.2) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.