Adding different context menu for datagrid's header

前端 未结 2 1641
悲哀的现实
悲哀的现实 2021-01-15 05:23

I want to add a different context menu for my datagrid\'s header on WPF. How can I do that?

2条回答
  •  渐次进展
    2021-01-15 06:26

    These resources will help you on the way:

    • Context Menus in WPF
    • WPF Context Menus
    • How to create Custom WPF Context Menus

    WPF used XAML which is another Markup Language and one common thing that you usualy see is that tags are reused on a lot of controls. In the examples above you can see that controls like

    • RichTextBox
    • Data Grid
    • And many more..

    Has the Control.ContextMenuwhere you can creat your specific menu for that item. Taken from the first link above, see this example on RichTextBox

    
        
            
            
         
    
    

    And this doesn't apply only to the ContextMenu! There are other reusable elements like this. Depending on what DataGrid you are using, you have to look into the API for that but it is most likely working its ways like this.

提交回复
热议问题