Custom attributes on element

5 posts, 0 answers
  1. Gediminas
    Gediminas avatar
    3 posts
    Member since:
    Oct 2012

    Posted 11 Nov 2014 Link to this post

    Hi,

    Is it posible to set and get custom attributes on Span, ImageInline, Table and other RadRichTextBox elements? Cant find any info in this topic.
  2. Gediminas
    Gediminas avatar
    3 posts
    Member since:
    Oct 2012

    Posted 11 Nov 2014 Link to this post

    Forgot to mention... I know of Tag element. But is it posible to add more.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Petya
    Admin
    Petya avatar
    975 posts

    Posted 13 Nov 2014 Link to this post

    Hi Gediminas,

    The Tag property is the only way to add custom information to a document element. You could serialize the desired information in a format convenient to you and add it there. 

    The other option to preserve custom attributes is through a custom annotation of some sorts. This help article explains in the details the concept and demonstrates how you could adopt it.

    Please note that in both cases the information will only be preserved when exporting the document to XAML format.

    Regards,
    Petya
    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.

     
  5. Gediminas
    Gediminas avatar
    3 posts
    Member since:
    Oct 2012

    Posted 14 Nov 2014 Link to this post

    Hello Petya,

    Thank you for your reply. I tried to sed json as Tag value, but get error

    {"'Quote characters ' or \" are only allowed at the start of values.' Line number '72' and line position '49'."}


    Inline with tag looks like this:

    <t:ImageInline Width="180" Height="120" Tag="{'Guid':'58cf11db-02a9-483e-9bf0-e2a05274d0cc','Type':'a','IsThumbnail':true}" Extension="png"/>


    while I try to import saved document. Is there a recomended way to store serialized data to tag without writing your own serializer?
  6. Petya
    Admin
    Petya avatar
    975 posts

    Posted 18 Nov 2014 Link to this post

    Hi Gediminas,

    In XAML curly brackets denote the start/end of a MarkupExtension which is the reason you are unable to place quote characters in it. You can escape the brackets to avoid the error like this:
    <t:ImageInline Width="180" Height="120" Tag="{}{'Guid':'58cf11db-02a9-483e-9bf0-e2a05274d0cc','Type':'a','IsThumbnail':true}" Extension="png"/>

    I hope this helps.

    Regards,
    Petya
    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 WPF is Visual Studio 2017 Ready