The Infragistics has many inbuilt various messages, some of them even misleading with context and causing lots of problems on adding workarounds.
One of the was discussed in my recently created post related to copy clipboard error on Virtual PC's here. There were way much more error messages were not from our code were raised and we had no way to control them. The last one is really raised by .NET framework but caught at Infragistics. In general we want to suspend this shown message and do not show it at all since functionality this works fine.
I would like to know how I can customize all various error/warning/informative messages raised by Infragistics (especially the one with copy to clipboard). If this is not possible I would request to provide ability to control these messages so we could define behavior (ignore/show) and replace with our text or completely display our custom message once it is hit.
Here is sample of stack trace showing misleading message on COPY to clipboard action and not on paste:
Stack trace of message:
PresentationFramework.dll!System.Windows.MessageBox.ShowCore(System.IntPtr owner, string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon, System.Windows.MessageBoxResult defaultResult, System.Windows.MessageBoxOptions options) Unknown PresentationFramework.dll!System.Windows.MessageBox.Show(System.Windows.Window owner, string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon, System.Windows.MessageBoxResult defaultResult) Unknown InfragisticsWPF.dll!Infragistics.Windows.Utilities.ShowMessageBox(System.Windows.DependencyObject element, string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon, System.Windows.MessageBoxResult defaultResult) Unknown InfragisticsWPF.Controls.Grids.XamSpreadsheet.dll!Infragistics.Controls.Grids.Core.SpreadsheetUtilities.ShowMessageBox(System.Windows.FrameworkElement associatedControl, string message, string caption, System.Windows.MessageBoxButton buttons, System.Windows.MessageBoxImage icon, System.Windows.MessageBoxResult defaultResult) Unknown InfragisticsWPF.Controls.Grids.XamSpreadsheet.dll!Infragistics.Controls.Grids.XamSpreadsheet.Infragistics.Controls.Grids.Core.ISpreadsheetView.ShowMessageBox(string message, string caption, System.Windows.MessageBoxButton buttons, System.Windows.MessageBoxImage icon, System.Windows.MessageBoxResult defaultResult) Unknown InfragisticsWPF.Controls.Grids.XamSpreadsheet.dll!Infragistics.Controls.Grids.Core.Spreadsheet.OnUserPrompt(Infragistics.Controls.Grids.Core.SpreadsheetUserPromptInfo promptInfo) Unknown InfragisticsWPF.Controls.Grids.XamSpreadsheet.dll!Infragistics.Controls.Grids.Core.Spreadsheet.CopyToClipboard.AnonymousMethod__265_4(object o, Infragistics.Controls.Grids.Core.WorkbookSerializationErrorEventArgs e) Unknown InfragisticsWPF.Controls.Grids.XamSpreadsheet.dll!Infragistics.Controls.Grids.Core.WorkbookDataObjectManager.RaiseSerializationError(bool isLoading, System.Exception exception) Unknown InfragisticsWPF.Controls.Grids.XamSpreadsheet.dll!Infragistics.Controls.Grids.Core.WorkbookDataObjectManager.CopyToClipboard(System.Func<bool> shouldProcessLargeCellCount) Unknown InfragisticsWPF.Controls.Grids.XamSpreadsheet.dll!Infragistics.Controls.Grids.Core.Spreadsheet.CopyToClipboard(bool cut) UnknownClipboard(bo
Hello Tomas,
My apologies, I must have missed your update to the other thread.
It is possible to customize this particular warning/error message raised by the XamSpreadsheet using its UserPromptDisplaying event. I haven’t been able to actually reproduce the error you are seeing locally, but this should fire and the event arguments allow you access to all of the parts of the message box as well as the ability to cancel the message box.
An alternative to this is to modify the resource string. The text “An error has occurred during the paste operation” is coming from a resource string, which can be overridden using the methods defined here: https://es.infragistics.com/help/wpf/developers-guide-customizing-resource-strings. It appears that the supported controls list needs to be updated, but this still should work for the XamSpreadsheet, as I have confirmed that the static XamSpreadsheet.RegisterResources method does exist.
The name of the specific resource string that you will want to overwrite in this case is “PasteError_General_Message” and so if you define this as a resource string in your own .resx file and register it using the XamSpreadsheet.RegisterResources method, this will allow you to modify it. For a full list of the resource string names, I would recommend downloading the Infragistics for WPF source code from your account as you will be able to find the .resx files there.
Note though, that this may cause issues if there is an actual paste error, but as mentioned in the other thread, there is an existing internal work item with a development ID of 273827 to have this fixed as the copy operation failure is throwing a paste message. The fix for this should be available in the next patch for 21.1 and 21.2. I will be linking this to a private support case for you that you can access after signing into your account, here: https://account.infragistics.com/support-cases.
Please let me know if you have any other questions or concerns on this matter.