Hello,
I'm using a XamDataGrid and the Copy/paste function.
When I paste on cell a value which is exactly the same than the current one, then my binded property is not updated.
Does it possible to have my property update after the paste even if the value has not changed ?
In my grid some field on different cell could have a specific behavior so I want my binded property is alert even if value is the same.
My version is : 16.2.20162.2237
Thanks by advance.
Hello Frederic,
I am under the impression in this case that you are referring to the XamDataGrid in the Infragistics for WPF product and not our UWP product. If this is the case, I will move the forum thread. If this is not the case, please let me know as the following is based on this impression.
Currently, the XamDataGrid will not change its underlying bound property if you paste the same value in the cell because put simply, the value is not actually changing. My best recommendation for you on this would be to utilize the ExecutedCommand event of the grid and catch the paste event. You could do that using the following event handler:
private void XamDataGrid_ExecutedCommand(object sender, Infragistics.Windows.Controls.Events.ExecutedCommandEventArgs e) { if(e.Command != null && e.Command.Name == "Paste") { //do something } }
In place of the “//do something” above, you could utilize the ActiveCell of the XamDataGrid to find the cell that you pasted into. The resulting Cell can get you the Record it is part of and the Field and should allow you to update your data item.
Please let me know if you have any other questions or concerns on this matter.
Yes i speak about WPF product so you can move it in the right place. Sorry for creating it at wrong place.
I will test your proposal and come back to you.
Thanks.
Hello Andrew,
I made this kind of solution to get all pasted Records and treat each pasted even if during paste the cell has not changed.
Do you think exist something more elegant ? Any tips to get all pasted record may be ?
private void DataGrid_OnExecutedCommand(object sender, ExecutedCommandEventArgs e) { if (e.Command != null && e.Command.Name == "Paste") { if (sender is XamDataGrid dataGrid) { var selectedItems = dataGrid.SelectedItems; foreach (var item in selectedItems.OfType<Cell>()) { var dataItem = item.Record.DataItem; if (dataItem is MyDataModel dataModel) { // the item has been pasted // toTreat.Add(dataModel) ..... } } } } }