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

[Solved] FontSize, DocumentInheritsDefaultStyleSettings & HtmlDataProvider

2 Answers 159 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
SHAWN
Top achievements
Rank 1
SHAWN asked on 19 Jul 2011, 07:17 PM
I am seeing inconsistent behavior with the FontSize property on the RadRichTextBox. . . .

Here are my Repro Steps:
1) file new silverlight project
2) drag a RadRichTextBox out of the tool box, keep all defaults, except ask for an HTML DataProvider
3) add the font size property to the xaml, you should have something that looks like this:

<telerik:RadRichTextBox DocumentInheritsDefaultStyleSettings="True"
                        HorizontalScrollBarVisibility="Hidden" IsContextMenuEnabled="True"
                        IsSelectionMiniToolBarEnabled="True" IsSpellCheckingEnabled="True"
                        Name="radRichTextBox1" VerticalScrollBarVisibility="Hidden"
                        FontSize="64">
    <telerik:RadRichTextBox.Resources>
        <my:HtmlDataProvider x:Key="provider" RichTextBox="{Binding ElementName=radRichTextBox1}" />
    </telerik:RadRichTextBox.Resources>
</telerik:RadRichTextBox>

Run the app and note that the font size is normal. . . .
Now comment out the HtmlDataProvider, you should have something that looks like this:
<telerik:RadRichTextBox DocumentInheritsDefaultStyleSettings="True"
                        HorizontalScrollBarVisibility="Hidden" IsContextMenuEnabled="True"
                        IsSelectionMiniToolBarEnabled="True" IsSpellCheckingEnabled="True"
                        Name="radRichTextBox1" VerticalScrollBarVisibility="Hidden"
                        FontSize="64">
    <telerik:RadRichTextBox.Resources>
        <!--<my:HtmlDataProvider x:Key="provider" RichTextBox="{Binding ElementName=radRichTextBox1}" />-->
    </telerik:RadRichTextBox.Resources>
</telerik:RadRichTextBox>

Run it again, note that the font inside the box is not respecting the default size we specified.

Now if we move the HtmlDataProvider outside of the RichTextBox, control we get the font size we want (note this is NOT how the Wizard generates the xaml):
<telerik:RadRichTextBox DocumentInheritsDefaultStyleSettings="True"
                        HorizontalScrollBarVisibility="Hidden" IsContextMenuEnabled="True"
                        IsSelectionMiniToolBarEnabled="True" IsSpellCheckingEnabled="True"
                        Name="radRichTextBox1" VerticalScrollBarVisibility="Hidden"
                        FontSize="64">
</telerik:RadRichTextBox>
<my:HtmlDataProvider RichTextBox="{Binding ElementName=radRichTextBox1}" />


2 Answers, 1 is accepted

Sort by
0
SHAWN
Top achievements
Rank 1
answered on 19 Jul 2011, 07:42 PM
Also note, that moving the HtmlDataProvider outside the RadRichTextBox trick doesn't work when you put the RichTextBox into an list box. . .

<ListBox ItemsSource="{Binding}">
    <ListBox.ItemTemplate>
        <DataTemplate>
                <StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding FirstName}" />
                        <TextBlock Text="{Binding LastName}" />
                    </StackPanel>
                    <telerik:RadRichTextBox Name="radRichTextBox1"
                    FontSize="64" DocumentInheritsDefaultStyleSettings="True">
                    </telerik:RadRichTextBox>
                    <my:HtmlDataProvider RichTextBox="{Binding ElementName=radRichTextBox1}" />
                </StackPanel>
            </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>
0
Iva Toteva
Telerik team
answered on 22 Jul 2011, 03:54 PM
Hi Shawn Weisfeld,

Thank you for reporting these issues. Actually, the XAML being generated by the wizard should be adjusted, so that the DataProviders are declared in the visual tree and not in the resources of the control. We will make sure to fix this issue for the next release.
As for the default font size not being applied, we will look into the matter and hopefully, fix it in due time. I have made some tests and it seems that when you bind the Html property of the provider, the default font size is applied. Another solution is to switch the places of the DataProvider and RadRichTextBox like this:

<ListBox ItemsSource="{Binding}">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <StackPanel>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding FirstName}" />
                    <TextBlock Text="{Binding LastName}" />
                </StackPanel>
                <my:HtmlDataProvider RichTextBox="{Binding ElementName=radRichTextBox1}" />
                <telerik:RadRichTextBox Name="radRichTextBox1"
            FontSize="64" DocumentInheritsDefaultStyleSettings="True">
                </telerik:RadRichTextBox>                    
            </StackPanel>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

The Telerik points in your account have been updated in appreciation of your involvement.

All the best,
Iva
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

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