Windows Phone 8.1 ,如何自定义Pivot头部样式?用Pivot控件完成这样的效果。

网上找了好久,只找到了windows phone 8的解决方案。 终于一个大神给支了招,我觉得我有必要跟诸位开发者分享一下经验。Windows Phone 8.1的开发资料实在太少了。我决定,用一个假期把我知道的都分享出来。

如果,你支持我的做法。请点赞或者评论本条博客、或者去 windows phone 应用商店 下载一个叫【有点意思】的app、再或者遥祝大黑兔减肥成功。 大黑兔将非常高兴。有点意思:http://www.windowsphone.com/zh-cn/store/app/%e6%9c%89%e7%82%b9%e6%84%8f%e6%80%9d/f2e705b4-5fd6-4c69-826b-c2f05c825ef0

好了,扯淡结束,开始工作。

1. 在App.xaml里定义自己的Pivot控件样式。下面的代码加在Application.Resources节点下,这样你的每一个页面就都能用到这个样式了。

 <Style TargetType="Pivot">

     <Setter Property="Template">

         <Setter.Value>

             <ControlTemplate TargetType="Pivot">

                 <Grid 

                     x:Name="RootElement" 

                     HorizontalAlignment="{TemplateBinding HorizontalAlignment}"

                     VerticalAlignment="{TemplateBinding VerticalAlignment}"

                     Background="{TemplateBinding Background}">

                     <VisualStateManager.VisualStateGroups>

                         <VisualStateGroup x:Name="Orientation">

                             <VisualState x:Name="Portrait">

                                 <Storyboard>

                                     <ObjectAnimationUsingKeyFrames Storyboard.TargetName="TitleContentControl" Storyboard.TargetProperty="Margin">

                                         <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource PivotPortraitThemePadding}" />

                                     </ObjectAnimationUsingKeyFrames>

                                 </Storyboard>

                             </VisualState>

                             <VisualState x:Name="Landscape">

                                 <Storyboard>

                                     <ObjectAnimationUsingKeyFrames Storyboard.TargetName="TitleContentControl" Storyboard.TargetProperty="Margin">

                                         <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource PivotLandscapeThemePadding}" />

                                   </ObjectAnimationUsingKeyFrames>

                               </Storyboard>

                           </VisualState>

                       </VisualStateGroup>

                   </VisualStateManager.VisualStateGroups>

                   <Grid.RowDefinitions>

                               <RowDefinition Height="Auto" />

                               <RowDefinition Height="*" />

                           </Grid.RowDefinitions>

                   <Border Background="Red">

                       <ContentControl x:Name="TitleContentControl"

                                       Style="{StaticResource PivotTitleContentControlStyle}"

                                       Content="{TemplateBinding Title}"

                                       ContentTemplate="{TemplateBinding TitleTemplate}"/>

                   </Border>

                   <ScrollViewer

                       x:Name="ScrollViewer"

                       Margin="{TemplateBinding Padding}"

                       Grid.Row="1"

                       HorizontalSnapPointsType="MandatorySingle"

                       HorizontalSnapPointsAlignment="Center"

                       HorizontalScrollBarVisibility="Hidden"

                       VerticalScrollMode="Disabled"

                       VerticalScrollBarVisibility="Disabled"

                       VerticalSnapPointsType="None"

                       VerticalContentAlignment="Stretch"

                       ZoomMode="Disabled"

                       Template="{StaticResource ScrollViewerScrollBarlessTemplate}">

                       <PivotPanel x:Name="Panel" VerticalAlignment="Stretch">

                           <PivotHeaderPanel x:Name="Header" Background="Red">

                               <PivotHeaderPanel.RenderTransform>

                                   <CompositeTransform x:Name="HeaderTranslateTransform" TranslateX="0" />

                               </PivotHeaderPanel.RenderTransform>

                           </PivotHeaderPanel>

                           <ItemsPresenter x:Name="PivotItemPresenter">

                               <ItemsPresenter.RenderTransform>

                                   <TranslateTransform x:Name="ItemsPresenterTranslateTransform" X="0" />

                               </ItemsPresenter.RenderTransform>

                           </ItemsPresenter>

                       </PivotPanel>

                   </ScrollViewer>

               </Grid>

           </ControlTemplate>

       </Setter.Value>

   </Setter>

 </Style>

2.在调用Pivot的页面中定义,primitives的namespace,加入以下代码。

xmlns:primitives="clr-namespace:Microsoft.Phone.Controls.Primitives;assembly=Microsoft.Phone"

3.在要使用Pivot的页面里,给Pivot指定这个样式:

<Pivot Style="{StaticResource DiaosbookPivotStyle}">
 
等等别走,点个赞再走~

WP8.1 Windows Phone 8.1开发:何如定义Pivot头部样式、定义Pivot头部颜色的更多相关文章

  1. Windows Phone 8.1 开发技术概览 (Universal APP)

    前一阵真的比较懒 WP8.1 已经出来这么长时间了现在才更新BLOG让大家久等了,今天我先为大家介绍下 WP 8.1的开发框架,什么是微软所推崇的 Universal APP,以及我们要开发 Univ ...

  2. windows phone 8.1开发SQlite数据库操作详解

    原文出自:http://www.bcmeng.com/windows-phone-sqlite1/ 本文小梦将和大家分享WP8.1中SQlite数据库的基本操作:(最后有整个示例的源码)(希望能通过本 ...

  3. 课程上线 -“新手入门 : Windows Phone 8.1 开发”

    经过近1个月的准备和录制,“新手入门 : Windows Phone 8.1 开发”系列课程已经在Microsoft 虚拟学院上线,链接地址为:http://www.microsoftvirtuala ...

  4. Windows下USB磁盘开发系列二:枚举系统中所有USB设备

    上篇 <Windows下USB磁盘开发系列一:枚举系统中U盘的盘符>介绍了很简单的获取系统U盘盘符的办法,现在介绍下如何枚举系统中所有USB设备(不光是U盘). 主要调用的API如下: 1 ...

  5. Windows平台下PHP开发环境的配置

    Windows平台下PHP开发环境的配置 一.基本环境 1.Windows XP 32位 2.Apache 2.2.25,下载地址:http://mirror.bit.edu.cn/apache/ht ...

  6. 《深入浅出Windows 10通用应用开发》

        <深入浅出Windows 10通用应用开发>采用Windows 10的SDK进行重新改版,整合了<深入浅出Windows Phone 8.1应用开发>和<深入解析 ...

  7. 2013-6-2 [转载自CSDN]如何入门Windows系统下驱动开发

    [序言]很多人都对驱动开发有兴趣,但往往找不到正确的学习方式.当然这跟驱动开发的本土化资料少有关系.大多学的驱动开发资料都以英文为主,这样让很多驱动初学者很头疼.本人从事驱动开发时间不长也不短,大概 ...

  8. Windows下搭建Git开发环境

    Windows下搭建Git开发环境主要有以下三种方法: 1,VS,vs2013和vs2015中已经集成了git插件了 2,msysGit+TortoiseGit 3,msysGit+SourceTre ...

  9. windows环境下Eclipse开发MapReduce程序遇到的四个问题及解决办法

    按此文章<Hadoop集群(第7期)_Eclipse开发环境设置>进行MapReduce开发环境搭建的过程中遇到一些问题,饶了一些弯路,解决办法记录在此: 文档目的: 记录windows环 ...

随机推荐

  1. joomla 出现The file Cache Storage is not supported on this platform;

    错误提示:The file Cache Storage is not supported on this platform:在这个平台上不支持文件缓存存储 出现这样的原因很简单,有两个文件夹不可写,这 ...

  2. 《剑指offer》---跳台阶问题

    本文算法使用python3实现 1. 问题1 1.1 题目描述:   一只青蛙一次可以跳上1级台阶,也可以跳上2级.求该青蛙跳上一个n级的台阶总共有多少种跳法.   时间限制:1s:空间限制:3276 ...

  3. win7 64位在线编辑dsoframer控件的安装和使用配置

    经历了两天的折磨,查阅了网上的资料,按网上的操作试了n种方法结果还是不行,开始以为是dsoframer 是32位控件问题,结果不是(经历了更改解决方案cpu,发布基于x86的网站:以为是操作系统问题, ...

  4. Dubbo分享

    1. Dubbo是什么? Dubbo是一个分布式服务框架,致力于提供高性能和透明化的RPC远程服务调用方案,以及SOA服务治理方案.简单的说,dubbo就是个服务框架,如果没有分布式的需求,其实是不需 ...

  5. python爬虫:爬取网站视频

    python爬取百思不得姐网站视频:http://www.budejie.com/video/ 新建一个py文件,代码如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 ...

  6. Calendar简单用法

  7. Apache Tomcat Nginx的区别和联系

    一.定义 1. Apache Apache HTTP服务器是一个模块化的服务器,可以运行在几乎所有广泛使用的计算机平台上.其属于应用服务器.Apache支持支持模块多,性能稳定,Apache本身是静态 ...

  8. BZOJ3926:[ZJOI2015]诸神眷顾的幻想乡——题解

    https://www.lydsy.com/JudgeOnline/problem.php?id=3926 https://www.luogu.org/problemnew/show/P3346 幽香 ...

  9. [Leetcode] search for a range 寻找范围

    Given a sorted array of integers, find the starting and ending position of a given target value. You ...

  10. UVA.10130 SuperSale (DP 01背包)

    UVA.10130 SuperSale (DP 01背包) 题意分析 现在有一家人去超市购物.每个人都有所能携带的重量上限.超市中的每个商品有其相应的价值和重量,并且有规定,每人每种商品最多购买一个. ...