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

Default Style problem

2 Answers 135 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Charles
Top achievements
Rank 1
Charles asked on 09 Mar 2012, 12:12 PM
Hi

I've followed this FAQ which explains that to set the Default Style, we can declaratively add the properties in XAML and set "DocumentInheritsDefaultStyle" to true.

I've done this, and open my document and type some text - it's in Times New Roman size 11.  If I add a table, all text added is in Times New Roman 11.

My problem is with tables.  If I check the built in styles TableNormal and TableGrid, they're actually set to Verdana 12.  Strange, then, that my table contains Times New Roman 11 text.

If I copy and paste the table somewhere else in the doument... all text changes to Verdana 12!

If anyone could explain:
- why copy and paste causes this change.  Surely if a table is a certain style or has certain overriden local values, they should remain?
- the difference between "TableNormal" and "TableGrid", and why we can't delete either via the UI.  And why, if I open a document without a TableGrid style, it creates one.

2 Answers, 1 is accepted

Sort by
0
Charles
Top achievements
Rank 1
answered on 09 Mar 2012, 01:02 PM
I've just tried importing a default template when I create a new file - this specifies the default style, and default fonts for the table styles (TableNormal, TableGrid).

I have removed the declared properties in Xaml (so it would be Verdana 12, but for the loading of this document).  The document markup is included below.

I still have the same issue - copy and pasting the tables results in Verdana 12.  However,  If I serialize to Xaml, the output doesn't mention Verdana 12. And if I re-import it, it displays as expected in Times New Roman 11....  curious!

Any help on this appreciated, as the inability to copy tables around a document without fear of screwing up the formatting is quite worrying!
<t:RadDocument xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:t="clr-namespace:Telerik.Windows.Documents.Model;assembly=Telerik.Windows.Documents" xmlns:s="clr-namespace:Telerik.Windows.Documents.Model.Styles;assembly=Telerik.Windows.Documents" version="1.2" LayoutMode="Paged" LineSpacing="1" LineSpacingType="Auto" ParagraphDefaultSpacingAfter="14.67" ParagraphDefaultSpacingBefore="0" SectionDefaultPageSize="816,1056" StyleName="defaultDocumentStyle">
  <t:RadDocument.ProtectionSettings>
    <t:DocumentProtectionSettings EnableDocumentProtection="True" Enforce="True" HashingAlgorithm="SHA1" HashingSpinCount="100000" PasswordHash="a+M7aLIv3xXP7Ce4ZcOa7OTSOfg=" ProtectionMode="ReadOnly" Salt="aI8vV7e36SnVOrkYzbyFnw==" />
  </t:RadDocument.ProtectionSettings>
  <t:RadDocument.Styles>
    <s:StyleDefinition DisplayName="Document Default Style" IsCustom="False" IsDefault="False" IsPrimary="True" Name="defaultDocumentStyle" Type="Default">
      <s:StyleDefinition.ParagraphStyle>
        <s:ParagraphProperties LineSpacing="1" SpacingAfter="14.67" />
      </s:StyleDefinition.ParagraphStyle>
      <s:StyleDefinition.SpanStyle>
        <s:SpanProperties FontFamily="Times New Roman" FontSize="14.67" FontStyle="Normal" FontWeight="Normal" />
      </s:StyleDefinition.SpanStyle>
    </s:StyleDefinition>
    <s:StyleDefinition DisplayName="TableNormal" IsCustom="False" IsDefault="True" IsPrimary="True" Name="TableNormal" Type="Table">
      <s:StyleDefinition.SpanStyle>
        <s:SpanProperties FontFamily="Times New Roman" FontSize="14.67" />
      </s:StyleDefinition.SpanStyle>
    </s:StyleDefinition
    <s:StyleDefinition BasedOnName="TableNormal" DisplayName="TableGrid" IsCustom="False" IsDefault="False" IsPrimary="True" Name="TableGrid" Type="Table">
      <s:StyleDefinition.SpanStyle>
        <s:SpanProperties FontFamily="Times New Roman" FontSize="14.67" />
      </s:StyleDefinition.SpanStyle>
      <s:StyleDefinition.TableStyle>
        <s:TableProperties Borders="1,None,#FF000000" />
      </s:StyleDefinition.TableStyle>
    </s:StyleDefinition>
    </t:RadDocument.Styles>
  <t:Section>
    <t:Paragraph />
  </t:Section>
</t:RadDocument>


0
Iva Toteva
Telerik team
answered on 14 Mar 2012, 02:47 PM
Hello Charles,

Thank you for reporting the copy/pasting issue. The problem is probably related to the way the properties are evaluated rather than the way they are set, therefore when you export the document, it is saved correctly. Furthermore, on loading the document anew, Times New Roman 11 is set to the paragraphs that have appeared as Verdana 12 before the export.

We have logged the issue as a bug and will try to fix it soon. However, due to the limited amount of time before the service pack, it is not very likely that the problem will be resolved in time.

When it comes to your other question - TableGrid and TableNormal are default table styles, which cannot be removed from the document. In addition, the TableNormal style cannot be modified via the UI. This is the behavior by design and is close to the way MS Word treats its Table Grid and Table Normal styles.

All the best,
Iva Toteva
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
RichTextBox
Asked by
Charles
Top achievements
Rank 1
Answers by
Charles
Top achievements
Rank 1
Iva Toteva
Telerik team
Share this question
or