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
80
How to subscribe to "Cut (Ctrl+X)" on XamGrid
posted

Is there a way to subscribe to the Cut event on a XamGrid. I have tried hooking to: 

In XAML:

ClipboardCopying="OnClipboardCopying"

In .cs:

private void OnClipboardCopying(object sender, ClipboardCopyingEventArgs e)

{
// Get selected cells
List<CellBase> selectedCells = new List<CellBase>(e.SelectedItems);

// Clear the style of the previously selected cells
if (_previouslySelectedCells != null && _previouslySelectedCells.Count > 0)
{
SetCellStyle(_previouslySelectedCells, null);
}

// Check if the selected region of cells is valid for pasting
bool IsValidSelectedRec = e.ValidateSelectedRectangle();

if (IsValidSelectedRec)
{
// Color in blue the valid cell selection
System.Windows.Style CellStyleResource = this.Resources["CutRowStyle"] as System.Windows.Style;
this.SetCellStyle(selectedCells, CellStyleResource);
}
else
{

// Cancel the copying event if the selected region of cells is not rectangular 
e.Cancel = true;
}


_previouslySelectedCells = selectedCells;
}

but the OnClipboardCopying function is just being called on a Copy and not a Cut operation. Is there any other way to get around it?

Thanks!

Parents Reply Children
No Data