首页 新闻 会员 周边

WPF TextBox 联动 Popup, Popup里面包含了GridViewDataControl, 输入中文报错。

0
悬赏园豆:15 [已解决问题] 解决于 2022-03-16 22:02

我是使用Popup里面的GridViewData代替了下拉框,输入之后可以可以根据代码和中文模糊查询,筛选出数据就把 Popup显示出来,反之隐藏。

输入1 ,可以带出如上数据,选择第一条,没问题,没有报错。

但是如果再此基础上再输入中文,就出现报错了。

错误如下:

丝毫没有头绪,不过我根据规律发现,只要TextBox联动的Popup里面不包含GridViewData 就不会报错,一旦加载了GridViewData 就会必现,整个系统崩溃。

【此错误可能是 CLR 中的 bug,或者是用户代码的不安全部分或不可验证部分中的 bug。此 bug 的常见来源包括用户对 COM-interop 或 PInvoke 的封送处理错误,这些错误可能会损坏堆栈。】

Windows 日志信息:

应用程序: ExportClient.exe
Framework 版本: v4.0.30319
说明: 应用程序通过 System.Environment.FailFast(string message) 请求终止进程。
消息: 不可恢复的系统错误。
堆栈:
在 System.Environment.FailFast(System.String)
在 MS.Internal.Invariant.FailFast(System.String, System.String)
在 System.Windows.Documents.TextStore.SetFinalDocumentState(MS.Internal.Documents.UndoManager, System.Collections.Stack, Int32, Int32, Int32, Int32, Int32)
在 System.Windows.Documents.TextStore.HandleCompositionEvents(Int32)
在 System.Windows.Documents.TextStore.GrantLockWorker(LockFlags)
在 System.Windows.Documents.TextStore.RequestLock(LockFlags, Int32 ByRef)
在 MS.Win32.UnsafeNativeMethods+ITfKeystrokeMgr.KeyDown(Int32, Int32, Boolean ByRef)
在 System.Windows.Input.TextServicesContext.Keystroke(Int32, Int32, KeyOp)
在 System.Windows.Input.TextServicesManager.TextServicesKeystroke(System.Windows.Input.TextServicesContext, System.Windows.Input.KeyEventArgs, Boolean)
在 System.Windows.Input.TextServicesManager.PostProcessInput(System.Object, System.Windows.Input.ProcessInputEventArgs)
在 System.Windows.Input.InputManager.RaiseProcessInputEventHandlers(System.Windows.Input.ProcessInputEventHandler, System.Windows.Input.ProcessInputEventArgs)
在 System.Windows.Input.InputManager.ProcessStagingArea()
在 System.Windows.Input.InputManager.ProcessInput(System.Windows.Input.InputEventArgs)
在 System.Windows.Input.InputProviderSite.ReportInput(System.Windows.Input.InputReport)
在 System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr, System.Windows.Input.InputMode, Int32, System.Windows.Input.RawKeyboardActions, Int32, Boolean, Boolean, Int32)
在 System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(System.Windows.Interop.MSG ByRef, Boolean ByRef)
在 System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(System.Windows.Interop.MSG ByRef, System.Windows.Input.ModifierKeys)
在 System.Windows.Interop.HwndSource.OnPreprocessMessage(System.Object)
在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
在 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
在 System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
在 System.Windows.Threading.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority, System.Delegate, System.Object)
在 System.Windows.Interop.HwndSource.OnPreprocessMessageThunk(System.Windows.Interop.MSG ByRef, Boolean ByRef)
在 System.Windows.Interop.HwndSource+WeakEventPreprocessMessage.OnPreprocessMessage(System.Windows.Interop.MSG ByRef, Boolean ByRef)
在 System.Windows.Interop.ThreadMessageEventHandler.Invoke(System.Windows.Interop.MSG ByRef, Boolean ByRef)
在 System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(System.Windows.Interop.MSG ByRef)
在 System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
在 System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)
在 System.Windows.Application.RunDispatcher(System.Object)
在 System.Windows.Application.RunInternal(System.Windows.Window)
在 System.Windows.Application.Run(System.Windows.Window)
在 System.Windows.Application.Run()
在 ExportClient.App.Main()

错误应用程序名称: ExportClient.exe,版本: 2.0.54.0,时间戳: 0x5f0677c2
错误模块名称: WindowsBase.ni.dll,版本: 4.8.4180.0,时间戳: 0x5e7d256c
异常代码: 0x80131623
错误偏移量: 0x0029a9e0
错误进程 ID: 0x4bd0
错误应用程序启动时间: 0x01d6559dcb67baa6
错误应用程序路径: F:\XXXXX
ExportClient\bin\Debug\ExportClient.exe
错误模块路径: C:\Windows\assembly\NativeImages_v4.0.30319_32\WindowsBase\f6a15e754119cc1cac9914d077eafb40\WindowsBase.ni.dll
报告 ID: 0d4c2d7c-a6a3-4e5e-87f7-6234f3eb9ce1
错误程序包全名:
错误程序包相对应用程序 ID:

居~的主页 居~ | 初学一级 | 园豆:28
提问于:2020-07-09 10:23

解决了这个问题,解决办法: 设置Textbox的UndoLimit 为0就ok。

解决办法的参考来源:https://blog.csdn.net/muzizongheng/article/details/9291683

久久婷婷 3年前
< >
分享
最佳答案
0

你其实已经说出了原因

  1. 中文
  2. Popup+gridviewdata
    任何一个因素不出现,就不会有BUG,那你想办法避免其中一个呗。
收获园豆:15
爱编程的大叔 | 高人七级 |园豆:30839 | 2020-07-09 10:29

这个目前开来不好简单处理,因为Popup里面包含gridviewdata是必要的,而且捕捉不到异常,直接系统崩溃。很难判断是具体拿一点导致的错误。

居~ | 园豆:28 (初学一级) | 2020-07-09 10:32

@久久婷婷: 那就不要输入中文呗。哈哈哈。
鱼与兄长不可兼得。

其实我明白你的潜台词,中文是一定要的。
所以必然的解决方案,就是不用这个组件,用其他实现方式。

当然还有一种可能性,就是你使用的中文输入法问题,你换个输入法(比如微软的)也许就行了。

爱编程的大叔 | 园豆:30839 (高人七级) | 2020-07-09 10:47

@爱编程的大叔: 微软更惨,中文输入模式下,中文还没出来就报错了。

居~ | 园豆:28 (初学一级) | 2020-07-09 15:06

@爱编程的大叔: 解决了这个问题,解决办法: 设置Textbox的UndoLimit 为0就ok。

解决办法的参考来源:https://blog.csdn.net/muzizongheng/article/details/9291683

居~ | 园豆:28 (初学一级) | 2020-07-10 10:47
其他回答(1)
0

解决了这个问题,解决办法: 设置Textbox的UndoLimit 为0就ok。

解决办法的参考来源:https://blog.csdn.net/muzizongheng/article/details/9291683

居~ | 园豆:28 (初学一级) | 2020-07-10 10:48
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册