为datagrid的标题添加其他上下文菜单 [英] Adding different context menu for datagrid's header

查看:66
本文介绍了为datagrid的标题添加其他上下文菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为WPF上的datagrid标题添加一个不同的上下文菜单.我该怎么办?

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

推荐答案

这些资源将在以下方面为您提供帮助:

These resources will help you on the way:

WPF使用了XAML,它是另一种标记语言,您通常会看到的一件事是,标记可以在许多控件上重用.在上面的示例中,您可以看到类似

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

具有 Control.ContextMenu ,您可以在其中创建该项目的特定菜单.从上面的第一个链接获取,请参见 RichTextBox

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

<RichTextBox>
    <RichTextBox.ContextMenu>
        <ContextMenu>
        </ContextMenu>
    </RichTextBox.ContextMenu> 
</RichTextBox>

这不仅适用于 ContextMenu !还有其他类似的可重用元素.根据所使用的DataGrid,您必须为此寻找API,但它很有可能以这种方式工作.

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.

这篇关于为datagrid的标题添加其他上下文菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆