TextBox的OnTextboxChanged事件里对Text重新赋值带中文, 导致崩溃
2013-07-10 15:42
190 查看
今天遇到一个超级bug, Textbox做了限制, 只能输入数字。 结果在搜狗输入法输入中文时导致崩溃, 出错信息如下:
未处理 System.InvalidOperationException
Message=无法关闭撤消单元,因为不存在已打开的单元。[/b]
Source=PresentationFramework
StackTrace:
在 MS.Internal.Documents.UndoManager.Close(IParentUndoUnit unit, UndoCloseAction closeAction)
在 System.Windows.Documents.ImmComposition.CloseCompositionUndoUnit(UndoCloseAction undoCloseAction, ITextPointer compositionEnd)
在 System.Windows.Documents.ImmComposition.UpdateCompositionText(FrameworkTextComposition composition, Int32 resultLength, Boolean includeResultText, ITextPointer& start, ITextPointer& end)
在 System.Windows.Documents.ImmComposition.RaiseTextInputStartEvent(FrameworkTextComposition composition, Int32 resultLength, String compositionString)
在 System.Windows.Documents.ImmComposition.OnWmImeChar(IntPtr wParam, Boolean& handled)
在 System.Windows.Documents.ImmComposition.ImmCompositionFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
在 System.Windows.Interop.HwndSource.PublicHooksFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
在 MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
在 MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
在 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
在 System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
在 MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
在 MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
在 MS.Win32.HwndSubclass.DefWndProcWrapper(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
在 MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
在 MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
在 MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
在 System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
在 System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
在 System.Windows.Application.RunDispatcher(Object ignore)
在 System.Windows.Application.RunInternal(Window window)
在 System.Windows.Application.Run(Window window)
在 System.Windows.Application.Run()
在 LiveChainCHIS_Client.App.Main() 位置 D:\项目\LiveChainCHIS-Client\LiveChainCHIS-Client\obj\x86\Debug\App.[/b]g.cs:行号 0
在 System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
InnerException:
补充说明一下 ,这个错误只出现于 数据绑定后的TextBox控件上。
解决办法: 设置Textbox的UndoLimit 为0就ok。
可以参考: http://social.msdn.microsoft.com/Forums/zh-CN/wpfzhchs/thread/06b9f4a1-d4a5-456b-bedc-ffc8f8019445
相关文章推荐
- TextBox的OnTextboxChanged事件里对Text重新赋值带中文, 导致崩溃
- TextBox的OnTextboxChanged事件里对Text重新赋值带中文, 导致崩溃
- TextBox的OnTextboxChanged事件里对Text重新赋值带中文, 导致崩溃
- textbox.text被赋值后无法得到用户重新输入的内容--[低级错误忘记在 Page_Load()里面加if (!IsPostBack) ]
- 关于重新实现TextView 的超链接点击事件
- ListView的Item里的TextView设置ClickableSpan和LinkMovementMethod导致ListView无法响应点击事件
- 给TextBox TextMode="password" 赋值后显示出来
- 中文里带半角空格导致的Text换行问题[Unity]
- 重新想象 Windows 8 Store Apps (1) - 控件之文本控件: TextBlock, TextBox, PasswordBox, RichEditBox, RichTextBlock, RichTextBlockOverflow
- TextBox JS前台赋值触发Onchange事件,屏蔽键盘操作
- easyui的textbox赋值问题,不能用$('#text&a 3ff8 pos;).val('text');赋值
- Wpf TextChanged事件导致死循环,事件触发循环问题
- TextBox控件TextMode="Password"時,觸發服務器端事件后,會清空掉TextBox的顯示值
- webBrowser.DocumentText重新赋值无效解决方法
- [置顶] js中click事件导致当前页面重新加载
- ArcGIS for Android 10.1.1API 中文标注导致程序异常崩溃问题
- html中input type="text" 的readonly 属性与asp.net服务器控件TextBox的readonly属性的js赋值、调用的小bug
- 中文输入法导致html input的onkeyup事件无法被触发,解决方法
- 重新想象 Windows 8 Store Apps (1) - 控件之文本控件: TextBlock, TextBox, PasswordBox, RichEditBox, RichTextBlock, RichTextBlockOverflow
- 【已解决】Android中在新线程中调用Toast.makeText导致程序崩溃