从Excel粘贴到WPF DataGrid

| 我有一个要在其上实现复制和粘贴功能的DataGrid(称为TheGrid)。复制功能很好用,但是我不知道如何实现粘贴。我是否只需要从剪贴板中获取数据并自己解析? 命令绑定:
<Window.CommandBindings>
    <CommandBinding Command=\"Copy\" Executed=\"CommandBinding_Executed\" CanExecute=\"CommandBinding_CanExecute\" />
    <CommandBinding Command=\"Paste\" Executed=\"CommandBinding_Executed\" CanExecute=\"CommandBinding_CanExecute\" />
</Window.CommandBindings>
菜单项:
<MenuItem Header=\"{x:Static culture:TextResource.CopyMenuItem}\" Command=\"Copy\"/>
<MenuItem Header=\"{x:Static culture:TextResource.PasteMenuItem}\" Command=\"Paste\"/>
CommandBinding_Executed的代码如下:
private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
{
    if(e.Command.Equals(ApplicationCommands.Copy))
    {
        // This works great, wow that was easy!
        ApplicationCommands.Copy.Execute(null, TheGrid);
    }
    else if (e.Command.Equals(ApplicationCommands.Paste))
    {
        //What do I do here? Is there an easy way to paste like there was for copy?
        // Or do I need to grab data using Clipboard.GetData and parse it myself?
    }
}
    
已邀请:
        这不容易做到 您应该使用
ClipboardHelper
解析剪贴板数据 看看这个问题     

要回复问题请先登录注册