要实现如上图所示的效果分为三步:

1.重写Pivot样式,去掉Pivot的Header或者是直接使用默认的Pivot的样式然后不写Header

2.使用一个ListView或者是横向的StackPanel或者是横向的Grid加上一个Button代替Header的效果(我使用的是Grid,建议使用ListView)

3.在Pivot的SelelctionChanged事件中以及当做Header的Button的Click事件做一个同步

首先Pivot的Item你想放什么就放什么

然后就是代替Header的问题:我用的Grid套了5个Button

 <Grid Grid.Row="" x:Name="TopBar" Background="#FDF187">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button x:Name="Header0" Style="{StaticResource GrayLightButton}"
Background="Transparent" Grid.Column="" Content="设置" FontFamily="Segoe MDL2 Assets,Segoe UI"
FontSize="" HorizontalAlignment="Center" VerticalAlignment="Center" Click="Header0_Click"/>
<Button x:Name="Header1" Style="{StaticResource GrayLightButton}"
Background="Transparent" Grid.Column="" Content="鸣谢" FontFamily="Segoe MDL2 Assets,Segoe UI"
FontSize="" HorizontalAlignment="Center" VerticalAlignment="Center" Click="Header1_Click"/>
<Button x:Name="Header2" Style="{StaticResource GrayLightButton}"
Background="Transparent" Grid.Column="" Content="开源与引用" FontFamily="Segoe MDL2 Assets,Segoe UI"
FontSize="" HorizontalAlignment="Center" VerticalAlignment="Center" Click="Header2_Click"/>
<Button x:Name="Header3" Style="{StaticResource GrayLightButton}"
Background="Transparent" Grid.Column="" Content="更新记录" FontFamily="Segoe MDL2 Assets,Segoe UI"
FontSize="" HorizontalAlignment="Center" VerticalAlignment="Center" Click="Header3_Click"/>
<Button x:Name="Header4" Style="{StaticResource GrayLightButton}"
Background="Transparent" Grid.Column="" Content="关于" FontFamily="Segoe MDL2 Assets,Segoe UI"
FontSize="" HorizontalAlignment="Center" VerticalAlignment="Center" Click="Header4_Click"/>
</Grid>

最后就是在后台代码中实现PivotItem与Grid的同步:

Pivot的SelelctionChanged事件实现Button的文字和颜色切换

 private void Pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Header0.Content = "设置";
Header0.FontSize = ;
Header0.Foreground = new SolidColorBrush(Color.FromArgb(, , , ));
Header1.Content = "鸣谢";
Header1.FontSize = ;
Header1.Foreground = new SolidColorBrush(Color.FromArgb(, , , ));
Header2.Content = "开源与引用";
Header2.FontSize = ;
Header2.Foreground = new SolidColorBrush(Color.FromArgb(, , , ));
Header3.Content = "更新记录";
Header3.FontSize = ;
Header3.Foreground = new SolidColorBrush(Color.FromArgb(, , , ));
Header4.Content = "关于";
Header4.FontSize = ;
Header4.Foreground = new SolidColorBrush(Color.FromArgb(, , , ));
switch (pivot.SelectedIndex)
{
case :
Header0.Content = "";//Segoe MDL2 Assets图标
Header0.FontSize = ;
Header0.Foreground = new SolidColorBrush(Color.FromArgb(, , , ));
break;
case :
Header1.Content = "";//Segoe MDL2 Assets图标
Header1.FontSize = ;
Header1.Foreground = new SolidColorBrush(Color.FromArgb(, , , ));
break;
case :
Header2.Content = "";//Segoe MDL2 Assets图标
Header2.FontSize = ;
Header2.Foreground = new SolidColorBrush(Color.FromArgb(, , , ));
break;
case :
Header3.Content = "";//Segoe MDL2 Assets图标
Header3.FontSize = ;
Header3.Foreground = new SolidColorBrush(Color.FromArgb(, , , ));
break;
case :
Header4.Content = "";//Segoe MDL2 Assets图标
Header4.FontSize = ;
Header4.Foreground = new SolidColorBrush(Color.FromArgb(, , , ));
break;
}
}

然后就是点击Button实现PivotItem的切换

以第一个Button举个栗子,以此类推

         private void Header0_Click(object sender, RoutedEventArgs e)
{
pivot.SelectedIndex = ;
pivot.SelectedItem = pivot.Items[];
}

就这样就可以实现如上效果了。

还可以做一个扩展:在Grid中Button下面加一扁扁的矩形,然后后台代码处理矩形的隐藏和出现,可以实现更加好看的效果。

抛砖引玉,如有更炫酷的方法请联系我~

Pivot-Header的花式效果的更多相关文章

  1. win10 uwp 修改Pivot Header 颜色

    我们在xaml创建一个Pivot <Pivot Grid.Row="1"> <PivotItem Header="lindexi">&l ...

  2. android自定义listview实现header悬浮框效果

    之前在使用iOS时,看到过一种分组的View,每一组都有一个Header,在上下滑动的时候,会有一个悬浮的Header,这种体验觉得很不错,请看下图: 上图中标红的1,2,3,4四张图中,当向上滑动时 ...

  3. react better-scroll 编写类似手机chrome的header显示隐藏效果

    关键代码 const H = 50; // header的高度 const H2 = H / 2; let cy = 0; class Home extends Component { @observ ...

  4. Panorama和Pivot控件

    Windows Phone提供了Panorama和Pivot这两种控件供用户横向切换导航的方式来显示具有内容比较相关的页面.本文主要对这两个控件进行描述,包括如何使用,以及一些最佳实践. 其中包括如下 ...

  5. 在后台代码中动态生成pivot项并设置EventTrigger和Action的绑定

    最近在做今日头条WP的过程中,遇到需要动态生成Pivot项的问题.第一个版本是把几个频道写死在xaml里了,事件绑定也写在xaml里,每个频道绑定一个ObservableCollection<A ...

  6. Pivot 和 Global 的一些总结

      相信大家一定有在 Unity 編輯器上看到這樣功能 這邊會跟大家說明這項功能有什麼用處     Pivot  意思為,輔助編輯的工具標示,會顯示在第一個選取的物件身上. Center 意思為,輔助 ...

  7. dotnet 从入门到放弃的 500 篇文章合集

    本文是记录我从入门到放弃写的博客 博客包括 C#.WPF.UWP.dotnet core .git 和 VisualStudio 和一些算法,所有博客使用 docx 保存 下载:dotnet 从入门到 ...

  8. Observable 示例之 Windows Phone 列表内项目逐个加载

    在写 Windows phone应用性能优化(一)的时候,在 ListBox 的项加载的时候,添加了一些简单的动画. 其实在 Windows Phone 的应用中使用 Blend 设计动画是很容易的, ...

  9. 2018-8-10-dotnet-从入门到放弃的-500-篇文章合集

    title author date CreateTime categories dotnet 从入门到放弃的 500 篇文章合集 lindexi 2018-08-10 19:16:52 +0800 2 ...

随机推荐

  1. 读书笔记-Software Testing(By Ron Patton)

    Software Testing Part I:The Big Picture 1.Software Testing Background Bug's formal definition 1.The ...

  2. 如何将md文件转换成带目录的html文件

    配置环境node 去官网下一个node安装包,下一步下一步: 由于现在的node都自带npm,直接 npm install i5ting_toc 这样安装好了i5ting_toc这个包, 进入你实现准 ...

  3. 【linux相识相知】用户及权限管理

    linux系统是多用户(Multi-users)和多任务(Multi-tasks)的,这样的目的是为了一台linux主机可以给很多用户提供服务同时运行多种服务,但是我们是怎么区分每个用户呢?作为一个管 ...

  4. 记一次SAP新业务开发项目

    直到笔者写这篇博文的时候,这个开发项目名义上已经上线,但其实开发以及优化的工作还在继续,数据的修复也仍在继续... IT系统环境很简单,一个基于JAVA+Mysql的Web平台,一个是宇宙第一的SAP ...

  5. PhpStorm配置PHP解释器(wampServer版)

    PHPStorm(以下简称为PS)和wampServer集成环境安装简单,不再赘述. 本人使用PhpStrom版本为2017.1.4版本. PS刚开始使用会使用自带服务器,但是有几率不能自动匹配到PH ...

  6. 访问Access日期字段

    在使用sql访问Access日期字段,应在变量前后加#,例子: s:=Format(select xueshID,name,times,qukbz,skdate,banji from dianmjil ...

  7. Servlet端 接收不到4096,8192长度的JSON参数

    Servlet端的日志显示,客户端传过来的JSON参数是空值. 但是在客户端的日志显示,已将JSON参数传送过去. 经调查发现,加减1位后的JSON参数均可以正常传送. 只有8192,4096长度的J ...

  8. 关于tomcat下startup.bat双击闪退的问题

    背景:之前做单点登录,复制了几个tomcat,改了各自端口,当做不同服务器用. 今天无意间随便点击了一个tomcat下的startup.bat批处理文件,结果出来控制台,没出几行信息就闪退了.点击其他 ...

  9. 基于android的语音质量评估

    最近研究如何通过android评估通话质量,希望获取的参数有:(1)接通时长 (2)掉话次数 (3)语音是否清晰,以下将给出接通时长和掉话次数的详细定义: 接通时长:通话一方开始拨号到另一方开始振铃的 ...

  10. Java中的数值和集合

    数组array和集合的区别: (1) 数值是大小固定的,同一数组只能存放一样的数据. (2) java集合可以存放不固定的一组数据 (3) 若程序事不知道究竟需要多少对象,需要在空间不足时自动扩增容量 ...