Hello,
the applied DarkMetroTheme style is not applied on the System.Windows.Controls.ContextMenu. What do I miss. In an larger project, I used the same code, and it works, but I don't see a difference.
Attached is a sample project. Right click on the tree node, an the context menu pops up, but not styled.
ContextMenuStyle.zip
Hello Markus,
Thank you for posting to the Infragistics.
I have been investigating this requirement that you are looking to achieve and found you are not using Microsoft ContextMenu which is not supported by Infragistics ThemeManager.You can find the list of all the supported Microsoft WPF controls here:
When you replace the Microsoft ContextMenu with the Infragistics XamContextMenu you will able to apply the theme useingThememanager.
Your code would be something like this:
private void OnContextMenuOpening(object sender, ContextMenuEventArgs e) { XamDataTreeNodeControl node = e.Source as XamDataTreeNodeControl; XamDataTree tree = node.Node.NodeLayout.Tree; var dataContext = node.DataContext as XamDataTreeNodeDataContext; //var nodeData = dataContext.Data as TreeNodeItem; ContextMenuManager contextMenuManager1 = new ContextMenuManager(); Infragistics.Controls.Menus.ContextMenuService.SetManager(tree, contextMenuManager1); XamContextMenu xamContextMenu1 = new XamContextMenu(); contextMenuManager1.ContextMenu = xamContextMenu1; XamMenuItem menuItemFont = new XamMenuItem { Header = "Font" }; xamContextMenu1.Items.Add(menuItemFont); // tree.ContextMenu = null; XamMenuItem item = null; // XamContextMenu m= new XamContextMenu(); //ree.m // item = new MenuItem(); //item = new XamMenuItem (); // item.Header = "Menu"; //item.Click += delegate (object sender1, RoutedEventArgs e1) //{ // //ConfigNodeItem configItem = ImagerSystemModel.CreateNewProductStreamItem(nodeData); // //propGrid.SelectedObject = configItem.Data; //}; //tree.ContextMenu.Items.Add(item); }
Please let me know if you need further assistance.
when using your code, the context menu appears only on the second right mouse click. Do you have the same experiance?
It is intrestin:, when I add the XamPropertyGrid control, the MS ContextMenu on the XamDataTree gets styled.
Thank you for the update.
Yes, I am getting the same behavior and it is expected because you are creating a ContextMenu when you fired ContextMenuOpening event instead if you create the XamContextMenu on page load and rest of the code in ContextMenuOpeningEvent you will see the context menu appears on the first click.
I have modified the sample application for your reference please find the sample and let me know if you need more information.
6646.ContextMenuStyle.zip