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

Crash when using PageLayoutSettings

5 Answers 102 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Iwhp
Top achievements
Rank 1
Iwhp asked on 08 Feb 2011, 12:05 AM
The following code crashes:

<navigation:Page x:Class="Designer.Ui.Silverlight.Home"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
                 xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                 mc:Ignorable="d"
                 d:DesignWidth="640"
                 d:DesignHeight="480"
                 Style="{StaticResource PageStyle}">

    <Grid x:Name="LayoutRoot">
                    <telerik:RadRichTextBox x:Name="RadRichTextBox1"
                                        Height="440"
                                        Width="440">
                    <telerik:RadRichTextBox.Document>
                        <telerik:RadDocument x:Name="RadDocument1" LayoutMode="Paged">
                            <telerik:RadDocument.DefaultPageLayoutSettings>
                                <telerik:PageLayoutSettings Height="400"
                                                            Width="400" />
                            </telerik:RadDocument.DefaultPageLayoutSettings>

                            <telerik:Section>
                                <telerik:Paragraph>
                                    <telerik:Span>
                                        Thank you for choosing Telerik
                                    </telerik:Span>
                                </telerik:Paragraph>
                            </telerik:Section>

                        </telerik:RadDocument>
                    </telerik:RadRichTextBox.Document>
                </telerik:RadRichTextBox>
    </Grid>

</navigation:Page>

Error message:

   at System.Windows.Navigation.PageResourceContentLoader.EndLoad(IAsyncResult asyncResult)
   at System.Windows.Navigation.NavigationService.ContentLoader_BeginLoad_Callback(IAsyncResult result)
Caused by: Exception has been thrown by the target of an invocation.

   at System.Windows.Navigation.PageResourceContentLoader.EndLoad(IAsyncResult asyncResult)
   at System.Windows.Navigation.NavigationService.ContentLoader_BeginLoad_Callback(IAsyncResult result)


When using code like this, it works:

            RadDocument document = new RadDocument();
            document.LayoutMode = DocumentLayoutMode.Paged;
            document.DefaultPageLayoutSettings.Width = 400;
            document.DefaultPageLayoutSettings.Height = 400;
            RadRichTextBox1.Document = document;

Any ideas?
Thankx, Harry

5 Answers, 1 is accepted

Sort by
0
Mike
Telerik team
answered on 09 Feb 2011, 02:37 PM
Hello Harry Pfleger,

The problem is most probably related to an issue of Silverlight with loading object properties that are of type float. In this case PageLayoutSetting.With and Height properties are float because of specifics of RadDocument measurement system. This is why we created a special type converter for the PageLayoutSettings class, which allows Height/Width properties to be specified as strings:
DefaultPageLayoutSettings="440,440"

I hope this helps.

Best wishes,
Mike
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Iwhp
Top achievements
Rank 1
answered on 10 Feb 2011, 09:54 AM
Hi Mike

thankx for the reply.
I changed my code to
<telerik:RadDocument x:Name="RadDocument1"
                                     LayoutMode="Paged"
                                     DefaultPageLayoutSettings="400,400">
and it did NOT work. Is this how it should be and work?

Cheers Harry
0
Iva Toteva
Telerik team
answered on 15 Feb 2011, 09:34 AM
Hello Harry,

Yes, this is how it should be.
I am attaching my demo for reference. Feel free to get back to us with a project of yours if you are unable to resolve the problem.

Regards,
Iva
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Iwhp
Top achievements
Rank 1
answered on 17 Feb 2011, 10:43 PM
Thankx Telerik Team... everything is fine now, I could reproduce a working sample here!
0
Iva Toteva
Telerik team
answered on 21 Feb 2011, 12:56 PM
Hello Harry Pfleger,

Good to hear that!
If you meet other difficulties, do not hesitate to get back to us.

Best wishes,
Iva
the Telerik team
Tags
RichTextBox
Asked by
Iwhp
Top achievements
Rank 1
Answers by
Mike
Telerik team
Iwhp
Top achievements
Rank 1
Iva Toteva
Telerik team
Share this question
or