WPF:从DataGrid复制 [英] WPF: Copy from a DataGrid

查看:110
本文介绍了WPF:从DataGrid复制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将复制功能添加到WPF数据网格.

I would like to add Copy functionality to a WPF DataGrid.

  1. 复制"选项应出现在右键菜单中
  2. 它应复制所选单元格的显示文本.(我使用的是只读文本列.)

推荐答案

在DataGrid的 ContextMenu 中,您可以创建 MenuItem 并设置 复制 .通过标准 ApplicationCommands 列表,因此无需其他任何代码即可使其起作用:

In the DataGrid's ContextMenu, you can create a MenuItem and set the MenuItem.Command value to Copy. It's a Command available through the standard ApplicationCommands list, so there won't be any additional code required to have it functional:

<DataGrid>
    <DataGrid.ContextMenu>
        <ContextMenu>
            <MenuItem Command="Copy" />
        </ContextMenu>
    </DataGrid.ContextMenu>
</DataGrid>

这篇关于WPF:从DataGrid复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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