當復制出現 以下錯誤時:System.Runtime.InteropServices.COMException (0x800401D0),這是在WPF剪貼板程序錯誤。
解決方法:則在需要在App.xaml.cs添加以下代碼
private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { var comException = e.Exception as System.Runtime.InteropServices.COMException; if (comException != null && comException.ErrorCode == -2147221040) { e.Handled = true; } }
一般是DataGridTextColumn是可以直接復制,如果是DataGridTemplateColumn,則需要在添加 ClipboardContentBinding="{Binding 綁定的屬性}"到
DataGridTemplateColumn中.