I have a DataGrid WPF with the following definition.
<DataGrid Name="DataGridFoo" AutoGenerateColumns="False" ItemsSource="{Binding GridData}" IsReadOnly="True" SelectionMode="Extended" SelectionUnit="CellOrRowHeader">
This allows me to select the "area" of cells. DataGrid is tied to the observed collection. XAML column definitions contain several columns, some of which look like this:
<DataGridTextColumn Binding="{Binding InvoiceID}" Header="Invoice ID" Visibility="Hidden" Width="Auto"/> <DataGridTextColumn Binding="{Binding InvoiceNumber}" Header="Invoice Number" Visibility="Visible" Width="Auto"/> <DataGridTextColumn Binding="{Binding InvoiceDate, StringFormat=\{0:MM/dd/yy\}}" Header="Invoice Date" Visibility="Visible" Width="Auto"/>
I also have a right-click context menu defined for a DataGrid:
<DataGrid.ContextMenu> <ContextMenu FontSize="16" Background="#FFE6E9EC"> <MenuItem Header="Contact" Click="Contact_Click" /> <Separator /> <MenuItem Header="Copy" Command="Copy" /> </ContextMenu> </DataGrid.ContextMenu>
I would like to be able to click, drag and delete a copy of selected cells into an external application. I thought to use a combination of pressing the Alt key and the Left mouse button to start the DragDrop operation.
For example, consider the "irregular" cell selection in a DataGrid:

I do not understand how to do this, and you have a few questions regarding this:
1) What events do I redefine so that left-clicking does not affect the selected cells?
2) . How to determine whether the left mouse button is clicked in the selected cell area? How to process a piece of data?
3) Once I have identified above, what will be the next step? Copy data to clipboard for use in external drop?
4) What events (if any) do I need to override in the DataGrid for this to work?
thanks