我正在开发一个wpf应用程序,它有一个绑定到FlowDocumentScrollViewer的FlowDocument。滚动FlowDocumentScrollViewer时,我收到一个InvalidOperationException:'This TextNavigator'没有作用域文本元素。这会导致应用程序崩溃。
例外详细信息:
System.InvalidOperationException: 'This TextNavigator' has no scoping text element.
at System.Windows.Documents.TextPointer.MoveToElementEdge(ElementEdge edge)
at System.Windows.Documents.TextPointer.System.Windows.Documents.ITextPointer.MoveToElementEdge(ElementEdge edge)
at System.Windows.Documents.TextPointerBase.GetFollowingNonMergeableInlineContentStart(ITextPointer position)
at System.Windows.Documents.TextSelection.get_PropertyPosition()
at System.Windows.Documents.TextSelection.GetCurrentValue(DependencyProperty formattingProperty)
at System.Windows.Documents.TextSelection.GetCaretBrush(TextEditor textEditor)
at System.Windows.Documents.TextSelection.UpdateCaretStateWorker(Object o)
at System.Windows.Documents.TextSelection.UpdateCaretState(CaretScrollMethod caretScrollMethod)
at System.Windows.Documents.TextSelection.System.Windows.Documents.ITextRange.NotifyChanged(Boolean disableScroll, Boolean skipEvents)
at System.Windows.Documents.TextRangeBase.EndChange(ITextRange thisRange, Boolean disableScroll, Boolean skipEvents)
at System.Windows.Documents.TextRange.System.Windows.Documents.ITextRange.EndChange(Boolean disableScroll, Boolean skipEvents)
at System.Windows.Documents.TextRange.ChangeBlock.System.IDisposable.Dispose()
at System.Windows.Documents.TextEditorMouse.OnMouseMoveWithFocus(TextEditor This, MouseEventArgs e)
at System.Windows.Documents.TextEditorMouse.OnMouseMove(Object sender, MouseEventArgs e)
at System.Windows.Input.MouseEventArgs.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(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(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.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
生成FlowDocument时没有任何异常。我一直在网上搜索,但没有找到可以提供帮助的信息。