锁定全景标题/图像

时间:2012-05-28 19:20:09

标签: windows-phone-7 windows-phone-7.1

有没有办法锁定全景控制标题,以便在切换页面时不会滑动?相反,它仍然在它的位置?

2 个答案:

答案 0 :(得分:2)

我可能会将全景放在一个有2行的网格中。第一行可以包含文本,图像或任何您想要保持静态的内容。然后将全景控件放在第二行内。看看这个:

<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>

答案 1 :(得分:0)

如果我理解正确,你不需要paralax title layer for panorama。

如果是这样,试试这个:

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

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

风格:

<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>