Marc Andreson
Marc Andreson

Reputation: 3495

Lock Panorama Title/Image

Is there a way to lock the Title of Panorama Control, so that it does not slide as the pages are switched? Instead it remains in its place?

Upvotes: 1

Views: 711

Answers (2)

Edward
Edward

Reputation: 7424

I would probably place the panorama inside of a grid with 2 rows. The first row can contain text, image or whatever you want to remain static. Then place the panorama control inside of the second row. Check this out:

<Grid x:Name="LayoutRoot">
    <Grid.RowDefinitions>
         <RowDefinition Height="60"/>
         <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <Image x:Name="Logo" Grid.Row="0"/>
    <controls:Panorama Grid.Row="1" Margin="0,-60,0,0">
         <controls:Panorama.Title><Rectangle Height="60"/></controls:Panorama.Title>
    ...
    </controls:Panorama>
</Grid>

Upvotes: 2

Roman Golenok
Roman Golenok

Reputation: 1417

If I understood you correctly you don't want paralax title layer for panorama.

If so, try this:

public class NoParalaxTitleLayer : PanningTitleLayer
    {
        protected override double PanRate
        {
            get { return 0d; }
        }
    }

    public class NoParalaxBackgroundLayer : PanningBackgroundLayer
    {
        protected override double PanRate
        {
            get { return 1d; }
        }
    }

And with style:

<Style x:Key="NonParalaxPanorama" TargetType="controls:Panorama">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="controls:Panorama">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>

                            <local:NoParalaxBackgroundLayer x:Name="BackgroundLayer" 
                 HorizontalAlignment="Left" Grid.RowSpan="2">
                                <Border x:Name="background" 
                    Background="{TemplateBinding Background}" 
                    CacheMode="BitmapCache"/>
                            </local:NoParalaxBackgroundLayer>
                            <local:NoParalaxTitleLayer x:Name="TitleLayer" 
                 CacheMode="BitmapCache" 
                 ContentTemplate="{TemplateBinding TitleTemplate}" 
                 Content="{TemplateBinding Title}" 
                 FontSize="187" 
                 FontFamily="{StaticResource PhoneFontFamilyLight}" 
                 HorizontalAlignment="Left" 
                 Margin="10,-76,0,9" Grid.Row="0"/>
                            <controlsPrimitives:PanningLayer x:Name="ItemsLayer" 
                 HorizontalAlignment="Left" Grid.Row="1">
                                <ItemsPresenter x:Name="items"/>
                            </controlsPrimitives:PanningLayer>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

<controls:Panorama Style="{StaticResource NonParalaxPanorama}">
</controls:Panorama>

Upvotes: 0

Related Questions