1

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

4

2 回答 2

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>
于 2012-05-29T00:21:47.163 回答
0

如果我理解正确,您不需要全景图的视差标题图层。

如果是这样,试试这个:

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>
于 2012-05-29T06:35:44.717 回答