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

Custom attribute injection for <t:Paragraph> tag. Is it possible?

6 Answers 88 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
vaitko
Top achievements
Rank 1
vaitko asked on 04 Aug 2011, 03:46 PM
Hi, currently i'm trying to use rich text box control (Telerik version 2011.2.712.1040) which is great, but i need one specific feature and not sure if its possible. I need support paragraph type which is internal term in our project, this means that our values which are richtext format should be divided into paragraphs (this is no problem) but paragraphs can have different types. For example:

lets say we some sample text in rich text box:

First paragraph
Second paragraph
Third paragraph

after:

var provider = new XamlFormatProvider();
this.Value = provider.Export(this.editor.Document);

Value field is:

<t:RadDocument xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" xmlns:t=\"clr-namespace:Telerik.Windows.Documents.Model;assembly=Telerik.Windows.Documents\" version=\"1.1\" DefaultPageLayoutSettings=\"816,1056\" LayoutMode=\"Flow\" PageViewMargin=\"0,0\" ParagraphDefaultSpacingAfter=\"0\" SectionDefaultPageMargin=\"6,6,6,6\">
   <t:Section>
      <t:Paragraph>
         <t:Span FontFamily=\"Verdana\" FontSize=\"16\" Text=\"First paragraph\" UnderlineColor=\"#FF000000\" UnderlineDecoration=\"None\" FontWeight=\"Normal\" FontStyle=\"Normal\" />
      </t:Paragraph>
      <t:Paragraph>
         <t:Span FontFamily=\"Verdana\" FontSize=\"16\" Text=\"Second paragraph\" UnderlineColor=\"#FF000000\" UnderlineDecoration=\"None\" FontWeight=\"Normal\" FontStyle=\"Normal\" />
      </t:Paragraph>
      <t:Paragraph>
         <t:Span FontFamily=\"Verdana\" FontSize=\"16\" Text=\"Third paragraph \" UnderlineColor=\"#FF000000\" UnderlineDecoration=\"None\" FontWeight=\"Normal\" FontStyle=\"Normal\" />
      </
t:Paragraph>
   </t:Section>
</t:RadDocument>

Also what i found allready i can identify which paragraph is currently "active" (in which paragraph is caret position):

this.editor.Document.CaretPosition.GetCurrentParagraphBox().ChildIndex

So the main question is is it possible to enrich Paragraph elements in rich text box value (pasted before) with smth like this:

<t:Paragraph Type="Type1"> ?

Thanks!

6 Answers, 1 is accepted

Sort by
0
vaitko
Top achievements
Rank 1
answered on 08 Aug 2011, 09:24 AM
So its not possible?
0
Iva Toteva
Telerik team
answered on 09 Aug 2011, 04:31 PM
Hello Gintaras Vaitkus,

Adding custom properties to document elements and persisting them is currently not supported. We are considering introducing support for custom properties, but the implementation of this feature has not been approved or scheduled yet.
The only solution for now would be to load the document using XDocument or XMLReader, add the property on export and strip it before import.

Greetings,
Iva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Øivind
Top achievements
Rank 1
answered on 10 Aug 2011, 06:55 AM
For your information:
We are also looking for exactly this kind of functionallity.

/Regards
Øivind Solberg   
PagePlanner Solutions
0
Iva Toteva
Telerik team
answered on 15 Aug 2011, 09:06 AM
Hello Øivind,

Thank you for your feedback.
As previously mentioned, we are considering adding this feature in the future.
Could you elaborate a little on the scenario you have in mind, e.g. what kind of properties you would be using, on which document elements (section, paragraph, etc.) they will be defined and what format will these properties need to be persisted in.

Best wishes,
Iva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Øivind
Top achievements
Rank 1
answered on 24 Aug 2011, 08:12 AM
Basically we need to build support for marking text and paragraphs with "styles".
So what we need is some way to "tag" spans and paragraphs.
We serialize the document to our own format so we have achieved this by (for now) using custom attached properties for "tagging" the elements(LayoutBoxes).

Thanks.

/Øivind
0
Iva Toteva
Telerik team
answered on 29 Aug 2011, 04:44 PM
Hello Øivind,

Thank you for following up with us on this matter.
In the upcoming Q3 release we will be introducing predefined styles along with their export and import in different file formats. Your scenario will probably benefit from this feature, too.

Greetings,
Iva
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
RichTextBox
Asked by
vaitko
Top achievements
Rank 1
Answers by
vaitko
Top achievements
Rank 1
Iva Toteva
Telerik team
Øivind
Top achievements
Rank 1
Øivind
Top achievements
Rank 1
Share this question
or