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

Bookmark Range (Rad RichTextBox - UI for WPF)

5 Answers 85 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Babu
Top achievements
Rank 1
Babu asked on 29 Oct 2014, 12:32 PM
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);

5 Answers, 1 is accepted

Sort by
0
Mihail
Telerik team
answered on 03 Nov 2014, 12:28 PM
Hello Babu,

I am not sure I understand what exactly the problem is. Could you provide information on the following questions:
  1. What operation are you executing to obtain the additional span and what is the overall goal of this task?
  2. Are you using selection for this matter or you are iterating over the inlines in the paragraph?
  3. 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);
0
Mihail
Telerik team
answered on 17 Nov 2014, 09:47 AM
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
 

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
Mihail
Telerik team
answered on 24 Nov 2014, 03:57 PM
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:
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.

 
Tags
Upload (Obsolete)
Asked by
Babu
Top achievements
Rank 1
Answers by
Mihail
Telerik team
Babu
Top achievements
Rank 1
Share this question
or