Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
260
Helper Class for Copying From Grid to Excel.
posted

I've taken the Copy from XamDataGrid example found here:

http://blogs.infragistics.com/wpf/articles/xamdatagrid-copying-to-excel-via-the-clipboard.aspx

and created a static helper class, that contains all the private static "copying to clip board" methods along with a public method to add copying.  This method is as follows.

 

 

 

 

 

 

public static class CopyHelper

{

 

 

public static void AddCopy(XamDataGrid grid, RoutedCommand copyCommand)

{

 

 

CommandBinding copyCommandBinding = new CommandBinding(copyCommand, ExecutedCopyCommand, CanExecuteCopyCommand);

 

 

grid.CommandBindings.Add(copyCommandBinding);

grid.InputBindings.Add(

new KeyBinding(copyCommand, new KeyGesture(Key.C, ModifierKeys.Control)));

 What are the drawbacks to calling this helper method as:

 CopyHelper.AddCopy(xamDataGrid1, new RoutedCommand());

 

 

 

 VS.

 

CopyHelper

 

.AddCopy(xamDataGrid1, CopyCommand);

Where CopyCommand is a static RoutedCommand.

 

The only thing that jumps out at me is that there may be a duplicate in the RoutedCommand should you add the copy ability to multiple grids, but maybe you guys see something I do not.

thanks in advance.

 

 

XamDataGrid_ClipboardSample.zip