如何删除枢轴标题但保留功能 [英] How to Remove the Pivot Header but Keep Functionality

查看:23
本文介绍了如何删除枢轴标题但保留功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在上一个问题 如何更改枢轴标题Windows Phone 8 中的模板 我重新设计了 Pivot 标头,但我想知道如何将标头全部删除,同时保持 PivotControl 的功能.

In a previous question How to Change Pivot Header Template in Windows Phone 8 I retemplated the Pivot Header, but I was wondering how it would be possible to remove the headers all together, while maintaining the functionality of a PivotControl.

推荐答案

这是我用于相同目的的解决方案,它工作正常:

Here's a solution that I use for the same purpose, it works fine:

<phone:PhoneApplicationPage.Resources>
    <Style x:Key="PivotStyle1" TargetType="phone:Pivot">
        <Setter Property="Margin" Value="0"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="phone:Pivot">
                    <Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
                        <primitives:PivotHeadersControl x:Name="HeadersListElement" />
                        <ItemsPresenter x:Name="PivotItemPresenter" Margin="{TemplateBinding Padding}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="PivotItemStyle1" TargetType="phone:PivotItem">
        <Setter Property="Margin" Value="0"/>
        <Setter Property="Padding" Value="0"/>
    </Style>
</phone:PhoneApplicationPage.Resources>

<phone:Pivot x:Name="MyPivot"
    Style="{StaticResource PivotStyle1}" ItemContainerStyle="{StaticResource PivotItemStyle1}">
    <phone:Pivot.ItemTemplate>
        <DataTemplate><!-- dummy content to show that no header is on the screen -->
            <Border BorderBrush="Blue" BorderThickness="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                <Grid Background="Red" />
            </Border>
        </DataTemplate>
    </phone:Pivot.ItemTemplate>
    <!-- we need empty header template to hide the pivotitem title completely -->
    <phone:Pivot.HeaderTemplate>
        <DataTemplate />
    </phone:Pivot.HeaderTemplate>
</phone:Pivot>

这篇关于如何删除枢轴标题但保留功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆