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
25
Interop (HwndSource, ElementHost) problems with cell validation and MessageBox
posted

Hello,

I am trying to use the XamDataGrid in an Interop scenario with Win32. The HwndSource class is used to host a WPF control which contains the datagrid. One column of the grid contains dates (DataTime objects). If one cell of this column is edited and I enter some nonsense value, the datagrid shows a messagebox (telling me that this is not a valid value). This works fine in a plain WPF application. But when this happens within a hosted scenario (either Win32 or WinForms) the application crashes (see the attached call stack for details).

It looks like the messagebox which should be shown gets an invalid owner window.

Does anyone know how to solve this problem? Of course one way could be to disable the feature that an messagebox is shown and handle it on my own. Is it possible to disable the showing of MessageBoxes?

 Thanks in advance,

  Bernd

 

 

PresentationFramework.dll!System.Windows.Interop.WindowInteropHelper.WindowInteropHelper(System.Windows.Window window) + 0x44 bytes     

               PresentationFramework.dll!System.Windows.MessageBox.Show(System.Windows.Window owner, string messageBoxText = "Value is invalid. Please enter a valid value.", string caption = "Invalid Value", System.Windows.MessageBoxButton button = OK, System.Windows.MessageBoxImage icon = Hand) + 0x1f bytes          

               Infragistics3.Wpf.Editors.v8.1.Express.dll!Infragistics.Windows.Editors.ValueEditor.a(bool A_0 = false, bool A_1 = false, out Infragistics.Windows.Editors.Events.EditModeValidationErrorEventArgs A_2 = {Infragistics.Windows.Editors.Events.EditModeValidationErrorEventArgs}, out bool A_3 = false) + 0xc4 bytes       

                Infragistics3.Wpf.Editors.v8.1.Express.dll!Infragistics.Windows.Editors.ValueEditor.EndEditMode(bool acceptChanges = true, bool force = false) + 0x2ae bytes   

                Infragistics3.Wpf.Editors.v8.1.Express.dll!Infragistics.Windows.Editors.ValuePresenter.EndEditMode(bool acceptChanges = true, bool force = false) + 0x4c bytes      

                Infragistics3.Wpf.DataPresenter.v8.1.Express.dll!Infragistics.Windows.DataPresenter.Cell.a(bool A_0 = true, bool A_1 = false) + 0x68 bytes              

                Infragistics3.Wpf.DataPresenter.v8.1.Express.dll!Infragistics.Windows.DataPresenter.Cell.EndEditMode() + 0x27 bytes      

                Infragistics3.Wpf.DataPresenter.v8.1.Express.dll!Infragistics.Windows.DataPresenter.DataPresenterBase.c(bool A_0 = false, bool A_1 = false) + 0x1ce bytes           

                Infragistics3.Wpf.DataPresenter.v8.1.Express.dll!Infragistics.Windows.DataPresenter.DataPresenterBase.a2() + 0x24 bytes      

                Infragistics3.Wpf.DataPresenter.v8.1.Express.dll!Infragistics.Windows.DataPresenter.DataPresenterBase.e(bool A_0 = true) + 0x58 bytes

                Infragistics3.Wpf.DataPresenter.v8.1.Express.dll!Infragistics.Windows.DataPresenter.DataPresenterBase.c(Infragistics.Windows.DataPresenter.Record A_0 = {DataRecord- 7 Shell: BTE}, bool A_1 = true) + 0x103 bytes  

                Infragistics3.Wpf.DataPresenter.v8.1.Express.dll!Infragistics.Windows.DataPresenter.DataPresenterBase.b(System.Windows.DependencyObject A_0 = {Infragistics.Windows.DataPresenter.XamDataGrid}, object A_1 = {DataRecord- 7 Shell: BTE}) + 0x58 bytes          

                WindowsBase.dll!System.Windows.DependencyObject.ProcessCoerceValue(System.Windows.DependencyProperty dp = {ActiveRecord}, System.Windows.PropertyMetadata metadata, ref System.Windows.EntryIndex entryIndex = {System.Windows.EntryIndex}, ref int targetIndex = 555, ref System.Windows.EffectiveValueEntry newEntry = {System.Windows.EffectiveValueEntry}, ref System.Windows.EffectiveValueEntry oldEntry = {System.Windows.EffectiveValueEntry}, ref object oldValue = {DataRecord- 6 Shell: BTE}, object baseValue = {DataRecord- 7 Shell: BTE}, System.Windows.CoerceValueCallback coerceValueCallback, bool coerceWithDeferredReference, bool skipBaseValueChecks) + 0x36 bytes 

                WindowsBase.dll!System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.EntryIndex entryIndex = {System.Windows.EntryIndex}, System.Windows.DependencyProperty dp = {ActiveRecord}, System.Windows.PropertyMetadata metadata = {System.Windows.FrameworkPropertyMetadata}, System.Windows.EffectiveValueEntry oldEntry, ref System.Windows.EffectiveValueEntry newEntry = {System.Windows.EffectiveValueEntry}, bool coerceWithDeferredReference, System.Windows.OperationType operationType = Unknown) + 0x361 bytes    

 

Parents
  • 54937
    Verified Answer
    Offline posted

    This issue has been logged and should be addressed in the next hotfix. For now, you can handle the ValueEditor.EditModeValidationError event and change the InvalidValueBehavior to something other than DisplayErrorMessage or Default - e.g. RetainValue, RevertValue. This situation can also happen when the datapresenter's DataError event is raised so you probably want to handle that event and set its Cancel to true and possibly show the message yourself from within that event.

Reply Children
No Data