Crash when using PageLayoutSettings

6 posts, 0 answers
  1. Iwhp
    Iwhp avatar
    40 posts
    Member since:
    Dec 2009

    Posted 07 Feb 2011 Link to this post

    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
  2. Mike
    Admin
    Mike avatar
    640 posts

    Posted 09 Feb 2011 Link to this post

    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>>
  3. Iwhp
    Iwhp avatar
    40 posts
    Member since:
    Dec 2009

    Posted 10 Feb 2011 Link to this post

    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
  4. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 15 Feb 2011 Link to this post

    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>>
  5. Iwhp
    Iwhp avatar
    40 posts
    Member since:
    Dec 2009

    Posted 17 Feb 2011 Link to this post

    Thankx Telerik Team... everything is fine now, I could reproduce a working sample here!
  6. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 21 Feb 2011 Link to this post

    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
Back to Top