Bookmark Range (Rad RichTextBox - UI for WPF)

Thread is closed for posting
6 posts, 0 answers
  1. Babu
    Babu avatar
    11 posts
    Member since:
    Feb 2014

    Posted 29 Oct 2014 Link to this post

    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);
  2. Mihail
    Admin
    Mihail avatar
    192 posts

    Posted 03 Nov 2014 Link to this post

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Babu
    Babu avatar
    11 posts
    Member since:
    Feb 2014

    Posted 12 Nov 2014 in reply to Mihail Link to this post

    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);
  5. Mihail
    Admin
    Mihail avatar
    192 posts

    Posted 17 Nov 2014 Link to this post

    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.

     
  6. Babu
    Babu avatar
    11 posts
    Member since:
    Feb 2014

    Posted 20 Nov 2014 in reply to Mihail Link to this post

    The sample code you have given me does not generate BookmarkRangeStart details in xaml. This is the issue i am facing. 
  7. Mihail
    Admin
    Mihail avatar
    192 posts

    Posted 24 Nov 2014 Link to this post

    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.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017