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
125
XamDataGrid Clipboard Operations via Right-Click Copy Command (include column headers)
posted

We have enabled clipboard operations in our XamDataGrid, but have also implemented a right-click Copy command via the ContextMenu, like so:

                 <igWPF:XamDataGrid.ContextMenu>

                     <ContextMenu>

                       <MenuItem Command="Copy"/>

                        <MenuItem Command="Paste"/>

                     </ContextMenu>

                 </igWPF:XamDataGrid.ContextMenu>

We would like to provide user the option of including field labels (or not) when they copy using the Context Menu, i.e. something like this:



Are there parameters to the Copy routed command that would support this feature?

Regards

  • 34810
    Verified Answer
    Offline posted

    Hello Jeannine,

    I have been investigating into this functionality that you are looking to achieve, and at the moment, there is no command parameter that you can pass to the "Copy" routed command for MenuItem that differentiates whether or not the grid should copy the headers of the selected cells' Fields or not. This is determined entirely by the XamDataGrid.FieldLayoutSettings.CopyFieldLabelsToClipboard bool property.

    As such, I would recommend creating your own command, and perhaps passing the XamDataGrid to it as a parameter. Inside, you can carry out the Copy operation by invoking the ExecuteCommand method and passing in the static DataPresenterCommand Copy command. The code for this would look like the following, where "xdg1" is the grid:

    xdg1.ExecuteCommand(DataPresenterCommands.Copy);

    If you were to toggle the XamDataGrid.FieldLayoutSettings.CopyFieldLabelsToClipboard property prior to the call to this method, you should be able to allow a Copy to Clipboard behavior with and without headers in the XamDataGrid.

    I hope this helps. Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer