Hello~
In ContentPane, when I mouse right button click I can see the context menu.
But I want to display the context menu when I click a button in the content pane tab header.
Is there a way?
There is no public method for showing the default context menu of a ContentPane. The context menu is shown from 3 sources - right click/shift-f10/apps key the ContentPane or PaneTabItem, right click on the caption area of a floating window that contains only 1 content pane, and use the Window Position menu item in the pane's header. Perhaps you can create your own ContextMenu or MenuItem and add MenuItem's that use the various ContentPaneCommands (e.g. Close, ChangeToDocument, etc.). To get the same look for the menuitems you can set the Style of those menu items to a dynamic resource pointing to the XamDockManager's MenuItemStyleKey.
Yes,
Here is the code snippet that I used to create this:
Popup p = new Popup();
p.Placement = PlacementMode.MousePoint;
ContentPane pane = Utilities.GetDescendantFromType(this, typeof(ContentPane), false) as ContentPane;
p.Child = new TextBlock() { Text = pane.ToolTip.ToString(), Foreground=Brushes.White};
p.IsOpen = true;
p.StaysOpen = false;
Alex.
Hello alex~
Thank you for quick reply. You mean , I have to make popup window(or user control) and then show the popup winodw?
Here is my xaml source...
<DataTemplate x:Key="myDataTemplate"> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding}" ToolTip="{Binding}"></TextBlock> <Button Name="btnShowContextMenu" /> </StackPanel> </DataTemplate>
This code used in ContentPane TabHeaderTeplate.
Hello,
To the best of my knowledge there is no way to do this directly.
What I could suggest is get the tooltip, place it in a Popup and then show the popup when the button is clicked.
Hope this helps,