Search code examples
windows-phone-7xamlwindows-phone-7.1panorama-control

First time I navigate to Panorama Page it gets too long to load


I'm developing a Windows Phone 7.1 application which has a panorama page.

This panorama page has two panorama items one with two textblock and the other one with a bing map control. And I also set a 1,5MB image as panorama control background.

This is Panorama's XAML:

<phone:PhoneApplicationPage 
    x:Class="XxXClass.DemoDetail"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="False" Foreground="{x:Null}" xmlns:my="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps">
    <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardIn"/>
            </toolkit:NavigationInTransition.Backward>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardIn"/>
            </toolkit:NavigationInTransition.Forward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardOut"/>
            </toolkit:NavigationOutTransition.Backward>
            <toolkit:NavigationOutTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardOut"/>
            </toolkit:NavigationOutTransition.Forward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>
    <!--LayoutRoot contains the root grid where all other page content is placed-->
    <Grid x:Name="LayoutRoot">
        <controls:Panorama Title="Demonstation Tracker">
            <controls:Panorama.Background>
                <ImageBrush Stretch="Fill" ImageSource="/Images/demonstrationPanorama.png"/>
            </controls:Panorama.Background>

            <!--Panorama item one-->
            <controls:PanoramaItem Header="Details">
                <Grid Background="#73000000" Margin="0,0,0,26">
                    <TextBlock Height="42" Margin="8,8,174,0" TextWrapping="Wrap" Text="XXXX" VerticalAlignment="Top" FontSize="{StaticResource PhoneFontSizeLarge}"/>
                    <TextBlock Margin="8,54,8,8" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Center" Height="413" Width="381" FontSize="{StaticResource PhoneFontSizeMedium}"><Run Text="xxx."/><Run Text=".."/></TextBlock>
                </Grid>
            </controls:PanoramaItem>

            <!--Panorama item two-->
            <controls:PanoramaItem Header="Map">
                <Grid>
                    <my:Map Name="map1" Margin="0,0,0,26" Height="420" Width="420" />
                </Grid>
            </controls:PanoramaItem>
        </controls:Panorama>
    </Grid>

    <!--Panorama-based applications should not show an ApplicationBar-->

</phone:PhoneApplicationPage>

First time I navigate to panorama page I gets too long to show, and if I tap on back button and I come back to it, it loads more quickly.

How can I make to panorama's page loads faster?


Solution

  • try to comment Map control. I'm sure that the problem with Map control. I always make data initialization in a background thread. Then when data are ready make BeginInvoke and redraw UI. And sure 1.5 MB is too Big, reduce it.