This is a migrated thread and some comments may be shown as answers.

How to make InlineUIContainer ReadOnly?

3 Answers 122 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
①Dr Mostafa
Top achievements
Rank 1
①Dr Mostafa asked on 11 Jan 2018, 06:01 PM

Hi every body...

In my application I have to make an InlineUIContainer (inserted within a table) as ReadOnly. To achieve this requirement I tried ReadOnlyRangeStart and ReadOnlyRangeEnd (as shown in the attached code). I also tried to InsertReadOnlyRange around the table using DocumentPosition (not shown in the attached code).  In both cases the following error is thrown:

"An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll"

Is not possible to make InlineUIContainer as ReadOnly? If so; is there any workaround?

Any Help Will Be Greatly Appreciated...

Note: the cause why I used TextBlocks instead of just adding new span to the paragraph; is that I have to make Text and image tightly grouped together; so that if they come across end of the page (and there is no enough space to them), then they move together to a new page. If there is a better solution to this requirement, it will be welcomed.

Private Function GetCenterManagerTable(ByVal mainDocument As RadDocument, ByVal FMMSContext As FMMS.BusinessObjects.Models.FMMSEntities) As Table
            Dim _table As New Table With {.Borders = New TableBorders(New Model.Border(1, BorderStyle.Single, Colors.Black)),
                                          .FlowDirection = GetFlowDirection(),
                                          .PreferredWidth = New TableWidthUnit(TableWidthUnitType.Fixed, mainDocument.SectionDefaultPageSize.Width - 115),
                                          .HorizontalAlignment = RadHorizontalAlignment.Center,
                                          .Tag = RequestTypes.WritingDraft}
            Dim _row As New TableRow
            Dim _cellReviewer As New TableCell With {.TextAlignment = RadTextAlignment.Center,
                                                     .Tag = RequestTypes.WritingDraft}
            Dim _cellManager As New TableCell With {.TextAlignment = RadTextAlignment.Center,
                                                    .Tag = Departments.CenterManager,
                                                    .PreferredWidth = New TableWidthUnit(TableWidthUnitType.Fixed, 350)}
            Dim _paragReviewer As New Paragraph With {.SpacingAfter = 0, .LineSpacingType = LineSpacingType.AtLeast, .LineSpacing = 0}
            Dim _paragManager As New Paragraph With {.SpacingAfter = 0, .LineSpacingType = LineSpacingType.AtLeast, .LineSpacing = 0}
 
            _table.Rows.Add(_row)
            _row.Cells.Add(_cellReviewer)
            _row.Cells.Add(_cellManager)
            _cellReviewer.Blocks.Add(_paragReviewer)
            _cellManager.Blocks.Add(_paragManager)
 
            'Manager
            Dim ManagerSignatureUIContainer As New InlineUIContainer With {.Width = 349, .Height = 200}
            Dim stckMain As New StackPanel With {.Height = 150}
            stckMain.Measure(New Size(350, 200))
            Dim txbName As New TextBlock With {.Text = ManagerData.Name, .FontFamily = PtHeadingFamily, .FontSize = 16, .TextWrapping = TextWrapping.Wrap, .HorizontalAlignment = HorizontalAlignment.Center}
            Dim imgManagerSignature As New Image With {.Name = "imgManagerSignature", .Width = 120, .Stretch = Stretch.Uniform}
            imgManagerSignature.Measure(New Size(120, 30))
            Dim txbSignatureDate As New TextBlock With {.Name = "txbSignatureDate", .FontFamily = New FontFamily("Times New Roman"), .FontSize = 8, .HorizontalAlignment = HorizontalAlignment.Center}
            Dim txbJob As New TextBlock With {.Text = ManagerData.Job, .FontFamily = PtHeadingFamily, .FontSize = 16, .TextWrapping = TextWrapping.Wrap, .HorizontalAlignment = HorizontalAlignment.Center}
            stckMain.Children.Add(txbName)
            stckMain.Children.Add(imgManagerSignature)
            stckMain.Children.Add(txbSignatureDate)
            stckMain.Children.Add(txbJob)
            ManagerSignatureUIContainer.UiElement = stckMain
 
            Dim rangeStart As New ReadOnlyRangeStart()
            Dim rangeEnd As New ReadOnlyRangeEnd()
            rangeEnd.PairWithStart(rangeStart)
 
            _paragManager.Inlines.Add(rangeStart)
            _paragManager.Inlines.Add(ManagerSignatureUIContainer)
            _paragManager.Inlines.Add(rangeEnd)
 
            Return _table
        End Function

3 Answers, 1 is accepted

Sort by
0
Boby
Telerik team
answered on 16 Jan 2018, 11:59 AM
Hello Mostafa,

At what point you are observing the exception?  We have the following issue logged in our public portal: RichTextBox: InlineUIContainer inside a ReadOnlyRange throws StackOverflowException on export to XAML

Could you confirm that the issue you are experiencing is the same? If yes, there is no good workaround, despite of moving the InlineUIContainer out of the read-only range, or using customized container export/import.

Regards,
Boby
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
①Dr Mostafa
Top achievements
Rank 1
answered on 16 Jan 2018, 04:34 PM

Thank you very much Body for your replay.....

Yes this error is thrown when exporting the document to XAML.

And by the way, I noticed the same error thrown when using RadDocumentEditor.SetWatermark to insert water mark programmatically.


0
①Dr Mostafa
Top achievements
Rank 1
answered on 16 Jan 2018, 05:31 PM

Sorry about the notice regarding the error thrown by RadDocumentEditor.SetWatermark.

There is no bug in this function, I used it in a wrong now, but now I'm able to use it correctly.

Thanx....


Tags
RichTextBox
Asked by
①Dr Mostafa
Top achievements
Rank 1
Answers by
Boby
Telerik team
①Dr Mostafa
Top achievements
Rank 1
Share this question
or