Bookmark Range is coming up with additional span text when linked with Heading Range.
Heading range comes with span text which is expected. But, we do not want the bookmark range to come up with additional span text.
BookmarkRangeStart, BookmarkRangeEnd, HeadingRangeStart, HeadingRangeEnd are derived from FieldRangeStartBase, FieldRangeEndBase, ContentRangeStartBase, ContentRangeEndBase, AnnotationRangeStart and AnnotationRangeEnd.
Below is sample code:
BookmarkRangeStart bookMarkRangeStart = new BookmarkRangeStart("bookmark1";
BookmarkRangeEnd bookMarkRangeEnd = new BookmarkRangeEnd();
bookMarkRangeEnd.PairWithStart(bookMarkRangeStart);
HeadingRangeStart headingRangeStart = new HeadingRangeStart();
HeadingRangeEnd headingRangeEnd = new HeadingRangeEnd();
headingRangeEnd.PairWithStart(headingRangeStart);
paragraph.Inlines.Add(bookMarkRangeStart);
paragraph.Inlines.Add(headingRangeStart);
paragraph.Inlines.Add(spanSelectedText);
paragraph.Inlines.Add(headingRangeEnd);
paragraph.Inlines.Add(bookMarkRangeEnd);
Heading range comes with span text which is expected. But, we do not want the bookmark range to come up with additional span text.
BookmarkRangeStart, BookmarkRangeEnd, HeadingRangeStart, HeadingRangeEnd are derived from FieldRangeStartBase, FieldRangeEndBase, ContentRangeStartBase, ContentRangeEndBase, AnnotationRangeStart and AnnotationRangeEnd.
Below is sample code:
BookmarkRangeStart bookMarkRangeStart = new BookmarkRangeStart("bookmark1";
BookmarkRangeEnd bookMarkRangeEnd = new BookmarkRangeEnd();
bookMarkRangeEnd.PairWithStart(bookMarkRangeStart);
HeadingRangeStart headingRangeStart = new HeadingRangeStart();
HeadingRangeEnd headingRangeEnd = new HeadingRangeEnd();
headingRangeEnd.PairWithStart(headingRangeStart);
paragraph.Inlines.Add(bookMarkRangeStart);
paragraph.Inlines.Add(headingRangeStart);
paragraph.Inlines.Add(spanSelectedText);
paragraph.Inlines.Add(headingRangeEnd);
paragraph.Inlines.Add(bookMarkRangeEnd);
5 Answers, 1 is accepted
0
Hello Babu,
I am not sure I understand what exactly the problem is. Could you provide information on the following questions:
Any additional information on what exactly is your scenario would be appreciated.
Regards,
Mihail
Telerik
I am not sure I understand what exactly the problem is. Could you provide information on the following questions:
- What operation are you executing to obtain the additional span and what is the overall goal of this task?
- Are you using selection for this matter or you are iterating over the inlines in the paragraph?
- Could you be more specific which types are your implementation and which are not as the FieldRangeStart/End classes that come with RadRichTextBox do not inhering from ContentRangeStartBase/End?
Any additional information on what exactly is your scenario would be appreciated.
Regards,
Mihail
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0

Babu
Top achievements
Rank 1
answered on 12 Nov 2014, 12:20 PM
1) The overall goal of this task is to insert bookmarks when we insert heading inside the richtextbox. And use them for navigation. Then the resulting richtextbox XAML should be generated as follows.
<t:BookmarkRangeStart AnnotationID="2" Name="H101f07da-205f-48ed-9131-721da28347bf" />
<t:BookmarkRangeEnd AnnotationID="2" />
<Paragraph>
<custom1:HeadingRangeStart AnnotationID="1" ControlId="101f07da-205f-48ed-9131-721da28347bf" />
<t:Span FontWeight="Bold" HighlightColor="#FFF5F5F5" Text="HeadingText —" />
<custom1:HeadingRangeEnd AnnotationID="1" />
<t:Span Text=" " />
</Paragraph>
2) We are using selected text.
3) HeadingRangeStart, BookmarkRangeStart are our custom classes which inherit from ContentRangeStartBase. HeadingRangeEnd, BookmarkRangeEnd are our custom classes which inherit from ContentRangeEndBase.
Sample code we are using:
BookmarkRangeStart bookMarkRangeStart = new BookmarkRangeStart("H001");
BookmarkRangeEnd bookMarkRangeEnd = new BookmarkRangeEnd();
bookMarkRangeEnd.PairWithStart(bookMarkRangeStart);
HeadingRangeStart headingRangeStart = new HeadingRangeStart("001");
HeadingRangeEnd headingRangeEnd = new HeadingRangeEnd();
headingRangeEnd.PairWithStart(headingRangeStart);
RadDocument tempDocument = new RadDocument();
Section section = new Section();
Paragraph paragraph = new Paragraph();
Span spanSelectedText = new Span(selectedText.TrimEnd());
spanSelectedText.FontWeight = FontWeights.Bold;
spanSelectedText.HighlightColor = Colors.WhiteSmoke;
paragraph.Inlines.Add(bookMarkRangeStart);
paragraph.Inlines.Add(bookMarkRangeEnd);
paragraph.Inlines.Add(headingRangeStart);
paragraph.Inlines.Add(spanSelectedText);
paragraph.Inlines.Add(headingRangeEnd);
<t:BookmarkRangeStart AnnotationID="2" Name="H101f07da-205f-48ed-9131-721da28347bf" />
<t:BookmarkRangeEnd AnnotationID="2" />
<Paragraph>
<custom1:HeadingRangeStart AnnotationID="1" ControlId="101f07da-205f-48ed-9131-721da28347bf" />
<t:Span FontWeight="Bold" HighlightColor="#FFF5F5F5" Text="HeadingText —" />
<custom1:HeadingRangeEnd AnnotationID="1" />
<t:Span Text=" " />
</Paragraph>
2) We are using selected text.
3) HeadingRangeStart, BookmarkRangeStart are our custom classes which inherit from ContentRangeStartBase. HeadingRangeEnd, BookmarkRangeEnd are our custom classes which inherit from ContentRangeEndBase.
Sample code we are using:
BookmarkRangeStart bookMarkRangeStart = new BookmarkRangeStart("H001");
BookmarkRangeEnd bookMarkRangeEnd = new BookmarkRangeEnd();
bookMarkRangeEnd.PairWithStart(bookMarkRangeStart);
HeadingRangeStart headingRangeStart = new HeadingRangeStart("001");
HeadingRangeEnd headingRangeEnd = new HeadingRangeEnd();
headingRangeEnd.PairWithStart(headingRangeStart);
RadDocument tempDocument = new RadDocument();
Section section = new Section();
Paragraph paragraph = new Paragraph();
Span spanSelectedText = new Span(selectedText.TrimEnd());
spanSelectedText.FontWeight = FontWeights.Bold;
spanSelectedText.HighlightColor = Colors.WhiteSmoke;
paragraph.Inlines.Add(bookMarkRangeStart);
paragraph.Inlines.Add(bookMarkRangeEnd);
paragraph.Inlines.Add(headingRangeStart);
paragraph.Inlines.Add(spanSelectedText);
paragraph.Inlines.Add(headingRangeEnd);
0
Hello Babu,
Thank you for the additional information.
I am afraid I still can't reproduce the described behavior. Could you modify the attached demo project in way that illustrates the issue you are experiencing.
Regards,
Mihail
Telerik
Thank you for the additional information.
I am afraid I still can't reproduce the described behavior. Could you modify the attached demo project in way that illustrates the issue you are experiencing.
Regards,
Mihail
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0

Babu
Top achievements
Rank 1
answered on 20 Nov 2014, 12:14 PM
The sample code you have given me does not generate BookmarkRangeStart details in xaml. This is the issue i am facing.
0
Hello Babu,
In order to achieve serialization you will have to add XamlSerializable attribute to the property you would like to serialize. Here is example on how to do it:
And here is the output:
I hope this information is helpful for you.
Regards,
Mihail
Telerik
In order to achieve serialization you will have to add XamlSerializable attribute to the property you would like to serialize. Here is example on how to do it:
public
class
BookmarkRangeStart : ContentRangeStartBase
{
public
BookmarkRangeStart()
{
this
.MyProperty = 4;
}
[XamlSerializable(0)]
public
int
MyProperty {
get
;
set
; }
}
And here is the output:
<
custom1:BookmarkRangeStart
AnnotationID
=
"1"
MyProperty
=
"4"
/>
<
custom1:BookmarkRangeEnd
AnnotationID
=
"1"
/>
I hope this information is helpful for you.
Regards,
Mihail
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.