C# 复印及;在MS Word中粘贴(XAML)

C# 复印及;在MS Word中粘贴(XAML),c#,.net,wpf,xaml,C#,.net,Wpf,Xaml,为什么我不能在MS Word中粘贴此XAML 我做了两次测试。这是第一个: string xaml = "<Window x:Class=\"WpfApplication2.MainWindow\"" + "xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\""+ "xmlns:x=\"http://schemas.microsoft.com/winfx

为什么我不能在MS Word中粘贴此XAML

我做了两次测试。这是第一个:

string xaml = "<Window x:Class=\"WpfApplication2.MainWindow\"" +
              "xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\""+
              "xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"" + 
              "Title=\"MainWindow\" Height=\"350\" Width=\"525\">" +
              "<Grid>" +
              "<Path Data=\"M119.33333,85 L317.50034,159.83333\" Fill=\"#FFF4F4F5\" HorizontalAlignment=\"Left\" Height=\"75.833\" Margin=\"119.333,85,0,0\" Stretch=\"Fill\" Stroke=\"Black\" VerticalAlignment=\"Top\" Width=\"199.167\"/>" +
              "<Rectangle Fill=\"#FFF4F4F5\" HorizontalAlignment=\"Left\" Height=\"95.333\" Margin=\"100.667,145.667,0,0\" Stroke=\"Black\" VerticalAlignment=\"Top\" Width=\"106\"/>" +
              "</Grid>" +
              "</Window>";

DataObject data = new DataObject(DataFormats.Xaml, xaml);

Clipboard.SetDataObject(data);
string xaml=“”+
"" +
"" +
"" +
"" +
"";
数据对象数据=新的数据对象(DataFormats.Xaml,Xaml);
剪贴板.SetDataObject(数据);
这是第二个:

string xaml = "<Path Stroke=\"Black\" StrokeThickness=\"1\" Fill=\"#CCCCFF\">" +
              "<Path.Data>" +
              "<GeometryGroup>" +
              "<RectangleGeometry Rect=\"50,5 100,10\" />" +
              "<RectangleGeometry Rect=\"5,5 95,180\" />" +
              "<EllipseGeometry Center=\"100, 100\" RadiusX=\"20\" RadiusY=\"30\"/>"+
              "<RectangleGeometry Rect=\"50,175 100,10\" />"+
               "<PathGeometry>"+
                 "<PathGeometry.Figures>"+
                   "<PathFigureCollection>" +
                     "<PathFigure IsClosed=\"true\" StartPoint=\"50,50\">"+
                       "<PathFigure.Segments>"+
                         "<PathSegmentCollection>"+
                           "<BezierSegment Point1=\"75,300\" Point2=\"125,100\" Point3=\"150,50\"/>"+
                           "<BezierSegment Point1=\"125,300\" Point2=\"75,100\"  Point3=\"50,50\"/>"+
                          "</PathSegmentCollection>"+
                         "</PathFigure.Segments>"+
                        "</PathFigure>"+
                       "</PathFigureCollection>"+
                      "</PathGeometry.Figures>"+
                     "</PathGeometry>"+
                    "</GeometryGroup>"+
                   "</Path.Data>"+
                  "</Path>";

DataObject data = new DataObject(DataFormats.Xaml, xaml);

Clipboard.SetDataObject(data);
string xaml=“”+
"" +
"" +
"" +
"" +
""+
""+
""+
""+
"" +
""+
""+
""+
""+
""+
""+
""+
""+
""+
""+
""+
""+
""+
"";
数据对象数据=新的数据对象(DataFormats.Xaml,Xaml);
剪贴板.SetDataObject(数据);

当应用程序(带有上述代码)仍在运行时,您是否正在粘贴它?您希望在Word中看到什么?逐字记录的文本?有什么魔力吗?@DrKotch:当然是矢量图。@Alberto我问,因为根据文档,你正在使用的
SetDataObject
重载,应用程序必须保持运行,才能在剪贴板上获得数据。。因此,如果应用程序正在运行,这应该不是问题所在。