An input issue (unexpected EditBox) when using DataGrid in MFC window

Nov 23, 2009 at 4:41 AM

Here is the details:

We are using WPF DataGrid in a MFC window. The DataGrid is implemented as a table for displaying and editing data (MultiBinding is used) in an User Control.  The User Control is embedded in a typical MFC window and we passed all the Dialog Inputs to the User Control ( DLGC_WANTALLKEYS). Then we noticed the following input issue:

When we edit a cell's value and hit "Enter", usually it will select the next cell in the same column automatically (This is also what we've expected), but sometime it will show an empty EditBox in the next cell in the same column. And the focus is in the EditBox.  This is very annoying since the behavoir is not consistent.  And even worse, when MultiBinding is used for that column, if we use mouse to hit some other area in the DataGrid, it will show the following exception related with Binding. Has anybody encountered the similar issue before? and Any ideas on resolving it? Thanks.

 PresentationFramework.dll!System.Windows.Data.BindingExpression.IsValidValueForUpdate(object value = 0.0, System.Type sourceType = null) + 0x24 bytes
PresentationFramework.dll!System.Windows.Data.BindingExpression.ConvertProposedValue(object value = 0.0) + 0x1b7 bytes
PresentationFramework.dll!System.Windows.Data.MultiBindingExpression.ConvertProposedValue(object value) + 0x409 bytes
PresentationFramework.dll!System.Windows.Data.BindingExpressionBase.UpdateValue() + 0x3e bytes
PresentationFramework.dll!System.Windows.Data.MultiBindingExpression.Update(bool synchronous) + 0x38 bytes
PresentationFramework.dll!System.Windows.Data.MultiBindingExpression.ReceiveWeakEvent(System.Type managerType, object sender, System.EventArgs e) + 0x96 bytes
PresentationFramework.dll!System.Windows.Data.BindingExpressionBase.System.Windows.IWeakEventListener.ReceiveWeakEvent(System.Type managerType, object sender, System.EventArgs e) + 0x11 bytes
WindowsBase.dll!System.Windows.WeakEventManager.DeliverEventToList(object sender = {System.Windows.Controls.TextBox}, System.EventArgs args = {System.Windows.RoutedEventArgs}, System.Windows.WeakEventManager.ListenerList list = {System.Windows.WeakEventManager.ListenerList}) + 0x59 bytes
WindowsBase.dll!System.Windows.WeakEventManager.DeliverEvent(object sender, System.EventArgs args) + 0xc9 bytes
PresentationFramework.dll!System.Windows.LostFocusEventManager.OnLostFocus(object sender, System.Windows.RoutedEventArgs args) + 0x9 bytes
PresentationCore.dll!System.Windows.RoutedEventHandlerInfo.InvokeHandler(object target, System.Windows.RoutedEventArgs routedEventArgs) + 0x78 bytes
PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(object source = {System.Windows.Controls.TextBox}, System.Windows.RoutedEventArgs args = {System.Windows.RoutedEventArgs}, bool reRaised = false) + 0x1bf bytes
PresentationCore.dll!System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject sender = {System.Windows.Controls.TextBox}, System.Windows.RoutedEventArgs args = {System.Windows.RoutedEventArgs}) + 0x79 bytes
PresentationCore.dll!System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs e) + 0x17 bytes
PresentationCore.dll!System.Windows.UIElement.OnLostFocus(System.Windows.RoutedEventArgs e) + 0x5 bytes
PresentationFramework.dll!System.Windows.Controls.Primitives.TextBoxBase.OnLostFocus(System.Windows.RoutedEventArgs e = {System.Windows.RoutedEventArgs}) + 0x12 bytes
PresentationCore.dll!System.Windows.UIElement.IsFocused_Changed(System.Windows.DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e) + 0xea bytes
WindowsBase.dll!System.Windows.DependencyObject.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e) + 0x4a bytes
PresentationFramework.dll!System.Windows.FrameworkElement.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e) + 0x50 bytes
PresentationFramework.dll!System.Windows.Controls.TextBox.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e) + 0x27 bytes
WindowsBase.dll!System.Windows.DependencyObject.NotifyPropertyChange(System.Windows.DependencyPropertyChangedEventArgs args) + 0x2c bytes
WindowsBase.dll!System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.EntryIndex entryIndex = {System.Windows.EntryIndex}, System.Windows.DependencyProperty dp = {IsFocused}, System.Windows.PropertyMetadata metadata, System.Windows.EffectiveValueEntry oldEntry, ref System.Windows.EffectiveValueEntry newEntry = {System.Windows.EffectiveValueEntry}, bool coerceWithDeferredReference, System.Windows.OperationType operationType) + 0x515 bytes
WindowsBase.dll!System.Windows.DependencyObject.ClearValueCommon(System.Windows.EntryIndex entryIndex, System.Windows.DependencyProperty dp, System.Windows.PropertyMetadata metadata) + 0xbb bytes
WindowsBase.dll!System.Windows.DependencyObject.ClearValue(System.Windows.DependencyPropertyKey key) + 0x45 bytes
PresentationCore.dll!System.Windows.Input.FocusManager.OnFocusedElementChanged(System.Windows.DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e) + 0x93 bytes
WindowsBase.dll!System.Windows.DependencyObject.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e) + 0x4a bytes
PresentationFramework.dll!System.Windows.FrameworkElement.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e) + 0x50 bytes
WindowsBase.dll!System.Windows.DependencyObject.NotifyPropertyChange(System.Windows.DependencyPropertyChangedEventArgs args) + 0x2c bytes
WindowsBase.dll!System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.EntryIndex entryIndex = {System.Windows.EntryIndex}, System.Windows.DependencyProperty dp = {FocusedElement}, System.Windows.PropertyMetadata metadata, System.Windows.EffectiveValueEntry oldEntry, ref System.Windows.EffectiveValueEntry newEntry = {System.Windows.EffectiveValueEntry}, bool coerceWithDeferredReference, System.Windows.OperationType operationType) + 0x515 bytes
WindowsBase.dll!System.Windows.DependencyObject.SetValueCommon(System.Windows.DependencyProperty dp, object value, System.Windows.PropertyMetadata metadata, bool coerceWithDeferredReference, System.Windows.OperationType operationType, bool isInternal) + 0x1eb bytes
WindowsBase.dll!System.Windows.DependencyObject.SetValue(System.Windows.DependencyProperty dp, object value) + 0x2e bytes
PresentationCore.dll!System.Windows.Input.FocusManager.SetFocusedElement(System.Windows.DependencyObject element, System.Windows.IInputElement value) + 0x2f bytes
PresentationFramework.dll!System.Windows.Input.KeyboardNavigation.UpdateFocusedElement(System.Windows.DependencyObject focusTarget = {Microsoft.Windows.Controls.DataGridCell: 0.00}) + 0x32 bytes
PresentationFramework.dll!System.Windows.FrameworkElement.OnGotKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e = {System.Windows.Input.KeyboardFocusChangedEventArgs}) + 0x47 bytes
PresentationCore.dll!System.Windows.Input.KeyboardFocusChangedEventArgs.InvokeEventHandler(System.Delegate genericHandler, object genericTarget) + 0x34 bytes
PresentationCore.dll!System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate handler, object target) + 0x27 bytes
PresentationCore.dll!System.Windows.RoutedEventHandlerInfo.InvokeHandler(object target, System.Windows.RoutedEventArgs routedEventArgs) + 0x3e bytes
PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(object source = {Microsoft.Windows.Controls.DataGridCell: 0.00}, System.Windows.RoutedEventArgs args = {System.Windows.Input.KeyboardFocusChangedEventArgs}, bool reRaised = false) + 0x1bf bytes
PresentationCore.dll!System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject sender = {Microsoft.Windows.Controls.DataGridCell: 0.00}, System.Windows.RoutedEventArgs args = {System.Windows.Input.KeyboardFocusChangedEventArgs}) + 0x79 bytes
PresentationCore.dll!System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs args = {System.Windows.Input.KeyboardFocusChangedEventArgs}, bool trusted) + 0x35 bytes
PresentationCore.dll!System.Windows.Input.InputManager.ProcessStagingArea() + 0x311 bytes
PresentationCore.dll!System.Windows.Input.InputManager.ProcessInput(System.Windows.Input.InputEventArgs input) + 0x42 bytes
PresentationCore.dll!System.Windows.Input.KeyboardDevice.ChangeFocus(System.Windows.DependencyObject focus, int timestamp) + 0x63e bytes
PresentationCore.dll!System.Windows.Input.KeyboardDevice.TryChangeFocus(System.Windows.DependencyObject newFocus, System.Windows.Input.IKeyboardInputProvider keyboardInputProvider, bool askOld, bool askNew, bool forceToNullIfFailed) + 0x12b bytes
PresentationCore.dll!System.Windows.Input.KeyboardDevice.Focus(System.Windows.DependencyObject focus, bool askOld, bool askNew) + 0xc2 bytes
PresentationCore.dll!System.Windows.Input.KeyboardDevice.Focus(System.Windows.IInputElement element) + 0x1a bytes
PresentationCore.dll!System.Windows.UIElement.Focus() + 0x1a bytes
WPFToolkit.dll!Microsoft.Windows.Controls.DataGridCell.OnAnyMouseLeftButtonDown(System.Windows.Input.MouseButtonEventArgs e = {System.Windows.Input.MouseButtonEventArgs}) Line 757 + 0x8 bytes C#
WPFToolkit.dll!Microsoft.Windows.Controls.DataGridCell.OnAnyMouseLeftButtonDownThunk(object sender = {Microsoft.Windows.Controls.DataGridCell: 0.00}, System.Windows.Input.MouseButtonEventArgs e = {System.Windows.Input.MouseButtonEventArgs}) Line 727 C#
PresentationCore.dll!System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(System.Delegate genericHandler, object genericTarget) + 0x31 bytes
PresentationCore.dll!System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate handler, object target) + 0x27 bytes
PresentationCore.dll!System.Windows.RoutedEventHandlerInfo.InvokeHandler(object target, System.Windows.RoutedEventArgs routedEventArgs) + 0x3e bytes
PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(object source = {Microsoft.Windows.Controls.DataGridCell: 0.00}, System.Windows.RoutedEventArgs args = {System.Windows.Input.MouseButtonEventArgs}, bool reRaised = true) + 0x1bf bytes
PresentationCore.dll!System.Windows.UIElement.ReRaiseEventAs(System.Windows.DependencyObject sender = {Microsoft.Windows.Controls.DataGridCell: 0.00}, System.Windows.RoutedEventArgs args = {System.Windows.Input.MouseButtonEventArgs}, System.Windows.RoutedEvent newEvent) + 0x10a bytes
PresentationCore.dll!System.Windows.UIElement.CrackMouseButtonEventAndReRaiseEvent(System.Windows.DependencyObject sender, System.Windows.Input.MouseButtonEventArgs e) + 0x2e bytes
PresentationCore.dll!System.Windows.UIElement.OnMouseDownThunk(object sender, System.Windows.Input.MouseButtonEventArgs e) + 0xde bytes
PresentationCore.dll!System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(System.Delegate genericHandler, object genericTarget) + 0x31 bytes
PresentationCore.dll!System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate handler, object target) + 0x27 bytes
PresentationCore.dll!System.Windows.RoutedEventHandlerInfo.InvokeHandler(object target, System.Windows.RoutedEventArgs routedEventArgs) + 0x3e bytes
PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(object source = {System.Windows.Controls.TextBlock}, System.Windows.RoutedEventArgs args = {System.Windows.Input.MouseButtonEventArgs}, bool reRaised = false) + 0x1bf bytes
PresentationCore.dll!System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject sender = {System.Windows.Controls.TextBlock}, System.Windows.RoutedEventArgs args = {System.Windows.Input.MouseButtonEventArgs}) + 0x79 bytes
PresentationCore.dll!System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs args = {System.Windows.Input.MouseButtonEventArgs}, bool trusted) + 0x35 bytes
PresentationCore.dll!System.Windows.Input.InputManager.ProcessStagingArea() + 0x311 bytes
PresentationCore.dll!System.Windows.Input.InputManager.ProcessInput(System.Windows.Input.InputEventArgs input) + 0x42 bytes
PresentationCore.dll!System.Windows.Input.InputProviderSite.ReportInput(System.Windows.Input.InputReport inputReport) + 0x62 bytes
PresentationCore.dll!System.Windows.Interop.HwndMouseInputProvider.ReportInput(System.IntPtr hwnd, System.Windows.Input.InputMode mode, int timestamp, System.Windows.Input.RawMouseActions actions, int x, int y, int wheel) + 0x2e2 bytes
PresentationCore.dll!System.Windows.Interop.HwndMouseInputProvider.FilterMessage(System.IntPtr hwnd = 396318, int msg = 513, System.IntPtr wParam = 1, System.IntPtr lParam = 11273264, ref bool handled = false) + 0x4e1 bytes
PresentationCore.dll!System.Windows.Interop.HwndSource.InputFilterMessage(System.IntPtr hwnd = 396318, int msg = 513, System.IntPtr wParam = 1, System.IntPtr lParam = 11273264, ref bool handled = false) + 0x75 bytes
WindowsBase.dll!MS.Win32.HwndWrapper.WndProc(System.IntPtr hwnd = 396318, int msg = 513, System.IntPtr wParam = 1, System.IntPtr lParam = 11273264, ref bool handled = false) + 0xbe bytes
WindowsBase.dll!MS.Win32.HwndSubclass.DispatcherCallbackOperation(object o) + 0x7a bytes
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback = {System.Windows.Threading.DispatcherOperationCallback}, object args = {MS.Win32.HwndSubclass.DispatcherOperationCallbackParameter}, bool isSingleParameter = true) + 0x8a bytes
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object source = {System.Windows.Threading.Dispatcher}, System.Delegate callback, object args, bool isSingleParameter, System.Delegate catchHandler = null) + 0x4a bytes
WindowsBase.dll!System.Windows.Threading.Dispatcher.WrappedInvoke(System.Delegate callback, object args, bool isSingleParameter, System.Delegate catchHandler) + 0x44 bytes
WindowsBase.dll!System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority priority, System.TimeSpan timeout, System.Delegate method, object args, bool isSingleParameter) + 0x91 bytes
WindowsBase.dll!System.Windows.Threading.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority priority, System.Delegate method, object arg) + 0x40 bytes
WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr hwnd = 396318, int msg = 513, System.IntPtr wParam = 1, System.IntPtr lParam = 11273264) + 0xdc bytes
[Frames below may be incorrect and/or missing, no symbols loaded for mscorwks.dll]
> mfc80d.dll!CThreadSlotData::GetThreadValue(int nSlot=-17213624)  Line 265 C++
[Native to Managed Transition]
user32.dll!7e418734()
user32.dll!7e418734()
user32.dll!7e418816()
user32.dll!7e4189cd()
user32.dll!7e418a10()
user32.dll!7e4274ff()
ntdll.dll!7c936f38()
user32.dll!7e43c6d3()
ntdll.dll!7c936f38()
ntdll.dll!7c9101db()
mfc80d.dll!CWnd::IsDialogMessageA(tagMSG * lpMsg=0x00057ed8)  Line 198 C++
mfc80d.dll!CWnd::PreTranslateInput(tagMSG * lpMsg=0x00057ed8)  Line 4268 C++
mfc80d.dll!CFormView::PreTranslateMessage(tagMSG * pMsg=0x00057ed8)  Line 230 C++
mfc80d.dll!CWnd::WalkPreTranslateTree(HWND__ * hWndStop=0x00040bc2, tagMSG * pMsg=0x00057ed8)  Line 2882 + 0x14 bytes C++
mfc80d.dll!AfxInternalPreTranslateMessage(tagMSG * pMsg=0x00057ed8)  Line 233 + 0x12 bytes C++
mfc80d.dll!CWinThread::PreTranslateMessage(tagMSG * pMsg=0x00057ed8)  Line 773 + 0x9 bytes C++
ds_mfcx.dll!CExWinApp::PreTranslateMessage(tagMSG * pMsg=0x00057ed8)  Line 607 C++
mfc80d.dll!AfxPreTranslateMessage(tagMSG * pMsg=0x00057ed8)  Line 252 + 0x11 bytes C++
mfc80d.dll!AfxInternalPumpMessage()  Line 178 + 0x18 bytes C++
mfc80d.dll!CWinThread::PumpMessage()  Line 896 C++
mfc80d.dll!CWinThread::Run()  Line 625 + 0xd bytes C++
mfc80d.dll!CWinApp::Run()  Line 894 C++
ds_mfcx.dll!CExWinApp::Run()  Line 503 + 0x8 bytes C++
mfc80d.dll!AfxWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00051f0b, int nCmdShow=5)  Line 47 + 0xd bytes C++
cfw.exe!WinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00051f0b, int nCmdShow=5)  Line 29 C++
cfw.exe!__tmainCRTStartup()  Line 578 + 0x35 bytes C
cfw.exe!WinMainCRTStartup()  Line 403 C
kernel32.dll!7c817067()
ntdll.dll!7c936f38()
ntdll.dll!7c9101db()