本文介绍了WPF在Focus()上崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在WPF中将焦点设置为TextBox控件时遇到了问题.我目前没有堆栈跟踪(在家中编写),但这是个问题:

推荐答案

堆栈跟踪:在System.Windows.Documents.TextStore.OnGotFocus()
在System.Windows.Documents.TextEditor.OnGotKeyboardFocus(Object sender,KeyboardFocusChangedEventArgs e)
在System.Windows.Controls.Primitives. TextBoxBase.OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
在System.Windows.UIElement.OnGotKeyboardFocusThunk(Object sender,KeyboardFocusChangedEventArgs e)
在System.Windows.Input.KeyboardFocusChangedEventArgs.InvokeEventHandler(Delegate) .System.Windows.RoutedEventHandlerInfo.InvokeHandler(对象目标,System.Windows.EventRoute.InvokeHandlersImpl(Object source,RoutedEventArgs args,Boolean)中的.Windows.RoutedEventArgs.InvokeHandler(委托处理程序,对象目标)
在System.Windows.UIElement.RaiseEventImpl(RoutedEventArgs args)处重新启动

在System.Windows.UIElement.RaiseEvent(RoutedEventArgs args,布尔值受信任)
处的System.Windows.UIElement.RaiseEventImpl(RoutedEventArgs args) Windows.Input.InputManager.ProcessStagingArea()
在System.Windows.Input.InputManager.ProcessInput(InputEventArgs输入)
在System.Windows.Input.KeyboardDevice.ChangeFocus(DependencyObject focus,Int32 timestamp)
在System.Windows.Input.KeyboardDevice.TryChangeFocus(DependencyObject newFocus,IKeyboardInputProvider keyboardInputProvider,布尔askOld,布尔askNew,布尔forceToNullIfFailed)在System.Windows.Input.KeyboardDevice.Focus(DependencyObject focus,Boolean askOld,Boolean askNew)
>在System.Windows.Input.KeyboardDevice.Focus(IInputElement元素)
在System.Windows.UIElement.Focus()
在System.Windows.FrameworkElement.OnPreviewGotKeyboardFocus(对象发送方,KeyboardFocusChangedEventArgs e)
System.Windows.RoutedEventArgs.InvokeHandler(Delegate处理程序,对象目标)
在System.Windows.RoutedE上的System.Windows.Input.KeyboardFocusChangedEventArgs.InvokeEventHandler(Delegate genericHandler,对象genericTarget)
ventHandlerInfo.InvokeHandler(对象目标,位于System.Windows.EventRoute.InvokeHandlersImpl(Object source,RoutedEventArgs args,Boolean reRaised)
的System.Windows.UIElement.RaiseEventImpl(RoutedEventArgs args)
System.Windows.Input.InputManager.ProcessStagingArea()处的System.Windows.UIElement.RaiseEvent(RoutedEventArgs args,布尔值受信任)
System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
处的System.Windows.Input.InputManager.ProcessStagingArea()
System.Windows.Input.KeyboardDevice.TryChangeFocus(DependencyObject newFocus,IKeyboardInputProvider keyboardInputProvider,布尔askOld,布尔askNew,布尔forceToNullIfFailed)在System.Windows.Input.KeyboardDevice.Focus(DependencyObject focus,Boolean askOld,Boolean askNew)
>在System.Windows.Input.KeyboardDevice.Focus(IInputElement元素)
在System.Windows.Input.Keyboard.Focus(IInputElement元素)
在System.Windows.Interop.HwndKeyboardInputProvider.OnRootChanged(V是System.Windows.Interop.HwndSource.set_RootVisualInternal(可视值)
上的isual oldRoot,Visual newRoot),在System.Windows.Window是System.Windows.Interop.HwndSource.set_RootVisual(Visual值)
上.在System.Windows.Window.CreateSourceWindowImpl()的SetupInitialState(Double requestTop,Double requestLeft,Double requestWidth,Double requestHeight)
在System.Windows.Window.SafeCreateWindow()
在System.Windows.Window. System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate回调,Object args,Boolean isSingleParameter)的ShowHelper(Object booleanBox)
System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source,Delegate callback,Object args) ,布尔值isSingleParameter,委托catchHandler)

 Stack Trace :    at System.Windows.Documents.TextStore.OnGotFocus()
   at System.Windows.Documents.TextEditor.OnGotKeyboardFocus(Object sender, KeyboardFocusChangedEventArgs e)
   at System.Windows.Controls.Primitives.TextBoxBase.OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
   at System.Windows.UIElement.OnGotKeyboardFocusThunk(Object sender, KeyboardFocusChangedEventArgs e)
   at System.Windows.Input.KeyboardFocusChangedEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.KeyboardDevice.ChangeFocus(DependencyObject focus, Int32 timestamp)
   at System.Windows.Input.KeyboardDevice.TryChangeFocus(DependencyObject newFocus, IKeyboardInputProvider keyboardInputProvider, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)
   at System.Windows.Input.KeyboardDevice.Focus(DependencyObject focus, Boolean askOld, Boolean askNew)
   at System.Windows.Input.KeyboardDevice.Focus(IInputElement element)
   at System.Windows.UIElement.Focus()
   at System.Windows.FrameworkElement.OnPreviewGotKeyboardFocus(Object sender, KeyboardFocusChangedEventArgs e)
   at System.Windows.Input.KeyboardFocusChangedEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.KeyboardDevice.TryChangeFocus(DependencyObject newFocus, IKeyboardInputProvider keyboardInputProvider, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)
   at System.Windows.Input.KeyboardDevice.Focus(DependencyObject focus, Boolean askOld, Boolean askNew)
   at System.Windows.Input.KeyboardDevice.Focus(IInputElement element)
   at System.Windows.Input.Keyboard.Focus(IInputElement element)
   at System.Windows.Interop.HwndKeyboardInputProvider.OnRootChanged(Visual oldRoot, Visual newRoot)
   at System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value)
   at System.Windows.Interop.HwndSource.set_RootVisual(Visual value)
   at System.Windows.Window.SetupInitialState(Double requestedTop, Double requestedLeft, Double requestedWidth, Double requestedHeight)
   at System.Windows.Window.CreateSourceWindowImpl()
   at System.Windows.Window.SafeCreateWindow()
   at System.Windows.Window.ShowHelper(Object booleanBox)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)


这篇关于WPF在Focus()上崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 15:06