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

Custom attributes on element

4 Answers 202 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Gediminas
Top achievements
Rank 1
Gediminas asked on 11 Nov 2014, 04:05 PM
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.

4 Answers, 1 is accepted

Sort by
0
Gediminas
Top achievements
Rank 1
answered on 11 Nov 2014, 04:30 PM
Forgot to mention... I know of Tag element. But is it posible to add more.
0
Petya
Telerik team
answered on 13 Nov 2014, 10:03 AM
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.

 
0
Gediminas
Top achievements
Rank 1
answered on 14 Nov 2014, 08:09 AM
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?
0
Petya
Telerik team
answered on 18 Nov 2014, 06:02 PM
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.

 
Tags
RichTextBox
Asked by
Gediminas
Top achievements
Rank 1
Answers by
Gediminas
Top achievements
Rank 1
Petya
Telerik team
Share this question
or