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. servlet映射路径

    1 访问映射过程 问题:访问URL:http://localhost:8080/day10/first  ,服务器如何相应的? 前提: tomcat服务器启动时,首先加载webapps中的每个web应 ...

  2. lintcode-39-恢复旋转排序数组

    39-恢复旋转排序数组 给定一个旋转排序数组,在原地恢复其排序. 说明 什么是旋转数组? 比如,原始数组为[1,2,3,4], 则其旋转数组可以是[1,2,3,4], [2,3,4,1], [3,4, ...

  3. arm交叉编译器gnueabi、none-eabi、arm-eabi、gnueabihf的区别

    转自 https://www.cnblogs.com/linuxbo/p/4297680.html 命名规则 交叉编译工具链的命名规则为:arch [-vendor] [-os] [-(gnu)eab ...

  4. Jedis源码解析——Jedis和BinaryJedis

    1.基本信息 先来看看他们的类定义: public class Jedis extends BinaryJedis implements JedisCommands, MultiKeyCommands ...

  5. Linux less命令语法

    一.Linux less命令语法 less [参数] 文件 less命令非常强大,在此只介绍几个常用的参数,更多参数使用man less来查看Linux帮助手册. -b <缓冲区大小> 设 ...

  6. CentOS基础命令

    为网卡配置静态IP地址建议通过交互式界面nmtui进行配置 firewalld和iptablesCentOS7使用firewald取代原来的iptables,但实际上底层还是iptables,在上层加 ...

  7. windows网络模型

    Windows提供了四种异步IO技术,机制几乎时相同的,区别在于通知结果的方式不同: 1.通过注册的消息函数进行通知 2.通过内核event事件进行通知 3.通过称为完成例程的回调函数进行通知 4.通 ...

  8. Elasticsearch 更新索引settings

    1.更新索引设置:将副本减至0,修改索引分析器为ik_max_word和检索分词器为ik_smart 2.需要先将索引关闭,然后再PUT setings POST user/_close PUT us ...

  9. hdu1950 Bridging signals

    LIS nlogn的时间复杂度,之前没有写过. 思路是d[i]保存长度为i的单调不下降子序列末尾的最小值. 更新时候,如果a[i]>d[len],(len为目前最长的单调不下降子序列) d[++ ...

  10. [NOI2009]管道取珠 DP + 递推

    ---题面--- 思路: 主要难点在思路的转化, 不能看见要求$\sum{a[i]^2}$就想着求a[i], 我们可以对其进行某种意义上的拆分,即a[i]实际上可以代表什么? 假设我们现在有两种取出某 ...