I am constructing a RadDocument in code. The document is protected, but contains several permission ranges where editing is allowed. The sections where editing is allowed contain some custom readonly ranges to further restrict editing. When I assign the RadDocument to the Document property on a RadRichTextBox, I get the exception and stack trace below in the RadDocument.IsInNonEditableRange function. I am using UI for WPF version 2014.1.331.40. The exception and stack trace are:
System.InvalidOperationException: Sequence contains more than one element
at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
at Telerik.Windows.Documents.Model.RadDocument.IsInNonEditableRange(Inline inline)
at Telerik.Windows.Documents.Model.PermissionChecker.CanExecuteRespectingWrappingReadOnlyRanges(RadDocument document, Boolean respectReadOnlyRanges, DocumentSelection selection, DocumentPosition position)
at Telerik.Windows.Documents.Model.PermissionChecker.CanExecuteRespectingRanges(RadDocument document, CanExecuteBehaviorInProtectedDocument canExecuteBehaviorInProtectedDocument, Boolean respectReadOnlyRanges, Boolean respectNonDeletableRanges, Boolean forDeleteOperation, DocumentSelection selection, DocumentPosition position)
at Telerik.Windows.Documents.Model.PermissionChecker.CanExecuteRespectingRanges(RadDocument document, CanExecuteBehaviorInProtectedDocument canExecuteBehaviorInProtectedDocument, Boolean respectReadOnlyRanges, Boolean respectNonDeletableRanges, Boolean forDeleteOperation)
at Telerik.Windows.Documents.RichTextBoxCommands.RichTextBoxCommandBase.CanExecuteRespectingRanges()
at Telerik.Windows.Documents.RichTextBoxCommands.RichTextBoxCommandBase..ctor(RadRichTextBox editor)
at Telerik.Windows.Documents.RichTextBoxCommands.SelectionEnabledCommand..ctor(RadRichTextBox editor)
at Telerik.Windows.Documents.RichTextBoxCommands.CutCommand..ctor(RadRichTextBox editor)
at Telerik.Windows.Documents.RichTextBoxCommands.RichTextBoxCommands.get_CutCommand()
at Telerik.Windows.Documents.RichTextBoxCommands.RichTextBoxCommands.InitializeApplicationCommandsMapping()
at Telerik.Windows.Documents.RichTextBoxCommands.RichTextBoxCommands.get_ApplicationCommandsMapping()
at Telerik.Windows.Documents.UI.DocumentWebLayoutPresenter.OnOwnerChanged()
at Telerik.Windows.Documents.UI.DocumentPresenterBase.set_Owner(RadRichTextBox value)
at Telerik.Windows.Controls.RadRichTextBox.InitActiveEditorPresenter(Boolean clearTextRelatedObjectPools)
at Telerik.Windows.Controls.RadRichTextBox.OnApplyTemplate()
at System.Windows.FrameworkElement.ApplyTemplate()
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Border.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Control.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.DockPanel.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Border.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Control.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.DockPanel.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.ContextLayoutManager.UpdateLayout()
at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
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)