2265
ContextMenu Style
posted

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

  • 5095
    Offline posted

    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.