WPF 基础控件之 TabControl样式

其他基础控件

1.Window
2.Button
3.CheckBox
4.ComboBox
5.DataGrid
6.DatePicker
7.Expander
8.GroupBox
9.ListBox
10.ListView
11.Menu
12.PasswordBox
13.TextBox
14.RadioButton
15.ToggleButton
16.Slider
17.TreeView

TabControl  实现下面的效果

e191e3f5a02624c55625317c808ce1be.png

1)TabControl来实现动画;

  • TabControl分为横向和纵向;

  • 横向Border设置RenderTransformScaleTransform.ScaleY="1",动画控制ScaleTransform.ScaleX01

  • 纵向Border设置RenderTransformScaleTransform.ScaleX="1",动画控制ScaleTransform.ScaleY01

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:sys="clr-namespace:System;assembly=mscorlib"xmlns:wpfs="clr-namespace:WPFDevelopers.Minimal.Helpers"><ResourceDictionary.MergedDictionaries><ResourceDictionary Source="../Themes/Basic/ControlBasic.xaml"/><ResourceDictionary Source="../Themes/Basic/Animations.xaml"/></ResourceDictionary.MergedDictionaries><Thickness x:Key="BorderThickness">0,0,0,2</Thickness><Style x:Key="BaseTAndBTabItem" TargetType="{x:Type TabItem}" BasedOn="{StaticResource ControlBasicStyle}"><Setter Property="Cursor" Value="Hand" /><Setter Property="Background" Value="Transparent" /><Setter Property="MinHeight" Value="48"/><Setter Property="MinWidth" Value="100"/><Setter Property="BorderThickness" Value="{StaticResource BorderThickness}"/><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type TabItem}"><Grid Background="{TemplateBinding Background}"><VisualStateManager.VisualStateGroups><VisualStateGroup x:Name="SelectionStates"><VisualState x:Name="Unselected" /><VisualState x:Name="Selected"><Storyboard><DoubleAnimation Duration="00:00:.2"To="1"Storyboard.TargetName="PART_Border"Storyboard.TargetProperty="(Border.RenderTransform).(ScaleTransform.ScaleX)"/></Storyboard></VisualState></VisualStateGroup><VisualStateGroup x:Name="CommonStates"><VisualState x:Name="Normal" /><VisualState x:Name="MouseOver" /><VisualState x:Name="Disabled"/></VisualStateGroup></VisualStateManager.VisualStateGroups><Border x:Name="PART_Border" BorderThickness="{TemplateBinding BorderThickness}"RenderTransformOrigin=".5,.5"><Border.RenderTransform><ScaleTransform ScaleX="0" ScaleY="1"/></Border.RenderTransform></Border><ContentPresenter ContentSource="Header"VerticalAlignment="Center" HorizontalAlignment="Center"/></Grid><ControlTemplate.Triggers><Trigger Property="IsSelected" Value="True"><Setter TargetName="PART_Border" Property="BorderBrush" Value="{DynamicResource PrimaryNormalSolidColorBrush}" /><Setter Property="Background" Value="{DynamicResource DefaultBackgroundSolidColorBrush}" /><!--<Setter Property="FontWeight" Value="Black"/>--><Setter Property="Foreground" Value="{DynamicResource PrimaryNormalSolidColorBrush}"/></Trigger><Trigger Property="IsMouseOver" Value="True"><Setter Property="Foreground" Value="{DynamicResource PrimaryNormalSolidColorBrush}"/></Trigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter></Style><Style x:Key="BaseLAndRTabItem" TargetType="{x:Type TabItem}" BasedOn="{StaticResource ControlBasicStyle}"><Setter Property="Cursor" Value="Hand" /><Setter Property="Background" Value="Transparent" /><Setter Property="MinHeight" Value="48"/><Setter Property="MinWidth" Value="100"/><Setter Property="BorderThickness" Value="{StaticResource BorderThickness}"/><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type TabItem}"><Grid Background="{TemplateBinding Background}"><VisualStateManager.VisualStateGroups><VisualStateGroup x:Name="SelectionStates"><VisualState x:Name="Unselected" /><VisualState x:Name="Selected"><Storyboard><DoubleAnimation Duration="00:00:.2"To="1"Storyboard.TargetName="PART_Border"Storyboard.TargetProperty="(Border.RenderTransform).(ScaleTransform.ScaleY)"/></Storyboard></VisualState></VisualStateGroup><VisualStateGroup x:Name="CommonStates"><VisualState x:Name="Normal" /><VisualState x:Name="MouseOver" /><VisualState x:Name="Disabled"/></VisualStateGroup></VisualStateManager.VisualStateGroups><Border x:Name="PART_Border" BorderThickness="{TemplateBinding BorderThickness}"RenderTransformOrigin=".5,.5"><Border.RenderTransform><ScaleTransform ScaleX="1" ScaleY="0"/></Border.RenderTransform></Border><ContentPresenter ContentSource="Header"VerticalAlignment="Center" HorizontalAlignment="Center"/></Grid><ControlTemplate.Triggers><Trigger Property="IsSelected" Value="True"><Setter TargetName="PART_Border" Property="BorderBrush" Value="{DynamicResource PrimaryNormalSolidColorBrush}" /><Setter Property="Background" Value="{DynamicResource DefaultBackgroundSolidColorBrush}" /><!--<Setter Property="FontWeight" Value="Black"/>--><Setter Property="Foreground" Value="{DynamicResource PrimaryNormalSolidColorBrush}"/></Trigger><Trigger Property="IsMouseOver" Value="True"><Setter Property="Foreground" Value="{DynamicResource PrimaryNormalSolidColorBrush}"/></Trigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter></Style><Style x:Key="LeftTabItem" TargetType="{x:Type TabItem}" BasedOn="{StaticResource BaseLAndRTabItem}"><Setter Property="BorderThickness" Value="0,0,2,0"/></Style><Style x:Key="RightTabItem" TargetType="{x:Type TabItem}" BasedOn="{StaticResource BaseLAndRTabItem}"><Setter Property="BorderThickness" Value="2,0,0,0"/></Style><Style x:Key="TopTabItem" TargetType="{x:Type TabItem}" BasedOn="{StaticResource BaseTAndBTabItem}"><Setter Property="BorderThickness" Value="0,0,0,2"/></Style><Style x:Key="BottomTabItem" TargetType="{x:Type TabItem}" BasedOn="{StaticResource BaseTAndBTabItem}"><Setter Property="BorderThickness" Value="0,2,0,0"/></Style><Style TargetType="{x:Type TabControl}" BasedOn="{StaticResource ControlBasicStyle}"><Setter Property="TabStripPlacement" Value="Top" /><!--<Setter Property="Margin" Value="2" />--><!--<Setter Property="Padding" Value="2"/>--><Setter Property="Background" Value="{DynamicResource WhiteSolidColorBrush}" /><Setter Property="ItemContainerStyle" Value="{StaticResource TopTabItem}"/><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type TabControl}"><Grid ClipToBounds="True" SnapsToDevicePixels="True" KeyboardNavigation.TabNavigation="Local"><Grid.ColumnDefinitions><ColumnDefinition Name="ColumnDefinition0"/><ColumnDefinition Width="0" Name="ColumnDefinition1" /></Grid.ColumnDefinitions><Grid.RowDefinitions><RowDefinition Height="Auto" Name="RowDefinition0" /><RowDefinition Height="*" Name="RowDefinition1" /></Grid.RowDefinitions><Border x:Name="HeaderBorder" BorderBrush="{DynamicResource BaseSolidColorBrush}" BorderThickness="0,0,0,1" Grid.Row="0"Background="{DynamicResource WhiteSolidColorBrush}"><TabPanel IsItemsHost="True"Name="HeaderPanel" Panel.ZIndex="1"KeyboardNavigation.TabIndex="1"/></Border><Grid Name="ContentPanel"KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local" KeyboardNavigation.DirectionalNavigation="Contained" Grid.Column="0" Grid.Row="1"><Border><ContentPresenter Content="{TemplateBinding SelectedContent}" ContentTemplate="{TemplateBinding SelectedContentTemplate}" ContentStringFormat="{TemplateBinding SelectedContentStringFormat}" ContentSource="SelectedContent" Name="PART_SelectedContentHost" Margin="2" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"  /></Border></Grid></Grid><ControlTemplate.Triggers><Trigger Property="TabControl.TabStripPlacement" Value="Bottom"><Setter TargetName="RowDefinition0" Property="RowDefinition.Height" Value="*" /><Setter TargetName="RowDefinition1" Property="RowDefinition.Height" Value="Auto" /><Setter TargetName="HeaderBorder" Property="Grid.Row" Value="1" /><Setter TargetName="ContentPanel" Property="Grid.Row" Value="0" /><Setter TargetName="HeaderBorder" Property="BorderThickness" Value="0,1,0,0" /><Setter Property="ItemContainerStyle" Value="{StaticResource BottomTabItem}"/></Trigger><Trigger Property="TabControl.TabStripPlacement" Value="Left"><Setter TargetName="ContentPanel" Property="Grid.Row" Value="0" /><Setter TargetName="ContentPanel" Property="Grid.Column" Value="1" /><Setter TargetName="ColumnDefinition0" Property="ColumnDefinition.Width" Value="Auto" /><Setter TargetName="ColumnDefinition1" Property="ColumnDefinition.Width" Value="*" /><Setter TargetName="RowDefinition0" Property="RowDefinition.Height" Value="*" /><Setter TargetName="RowDefinition1" Property="RowDefinition.Height" Value="0" /><Setter TargetName="HeaderBorder" Property="BorderThickness" Value="0,0,1,0" /><Setter Property="ItemContainerStyle" Value="{StaticResource LeftTabItem}"/></Trigger><Trigger Property="TabControl.TabStripPlacement" Value="Right"><Setter TargetName="ContentPanel" Property="Grid.Row" Value="0" /><Setter TargetName="HeaderBorder" Property="Grid.Column" Value="1" /><Setter TargetName="ContentPanel" Property="Grid.Column" Value="0" /><Setter TargetName="ColumnDefinition0" Property="ColumnDefinition.Width" Value="*" /><Setter TargetName="ColumnDefinition1" Property="ColumnDefinition.Width" Value="Auto" /><Setter TargetName="RowDefinition0" Property="RowDefinition.Height" Value="*" /><Setter TargetName="RowDefinition1" Property="RowDefinition.Height" Value="0" /><Setter TargetName="HeaderBorder" Property="BorderThickness" Value="1,0,0,0" /><Setter Property="ItemContainerStyle" Value="{StaticResource RightTabItem}"/></Trigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter></Style></ResourceDictionary>

2)Styles.TabControl.xaml 代码如下;

<UniformGrid Columns="2" Rows="2" Margin="0,10"><UniformGrid.Resources><Style TargetType="{x:Type Rectangle}"><Setter Property="Width" Value="{x:Static SystemParameters.PrimaryScreenWidth}"/><Setter Property="Height" Value="400"/></Style></UniformGrid.Resources><TabControl><TabItem Header="TabItem1"><Rectangle Fill="{DynamicResource DangerSolidColorBrush}"/></TabItem><TabItem Header="TabItem2"><Rectangle Fill="{DynamicResource InfoSolidColorBrush}"/></TabItem><TabItem Header="TabItem3" ><Rectangle Fill="{DynamicResource WarningSolidColorBrush}"/></TabItem></TabControl><TabControl TabStripPlacement="Bottom"><TabItem Header="TabItem1"><Rectangle Fill="{DynamicResource InfoSolidColorBrush}"/></TabItem><TabItem Header="TabItem2"><Rectangle Fill="{DynamicResource DangerSolidColorBrush}"/></TabItem><TabItem Header="TabItem3" ><Rectangle Fill="{DynamicResource WarningSolidColorBrush}"/></TabItem></TabControl><TabControl TabStripPlacement="Left"><TabItem Header="TabItem1"><Rectangle Fill="{DynamicResource WarningSolidColorBrush}"/></TabItem><TabItem Header="TabItem2"><Rectangle Fill="{DynamicResource InfoSolidColorBrush}"/></TabItem><TabItem Header="TabItem3" ><Rectangle Fill="{DynamicResource DangerSolidColorBrush}"/></TabItem></TabControl><TabControl TabStripPlacement="Right" IsEnabled="False"><TabItem Header="TabItem1"><Rectangle Fill="{DynamicResource SuccessSolidColorBrush}"/></TabItem><TabItem Header="TabItem2"><Rectangle Fill="{DynamicResource InfoSolidColorBrush}"/></TabItem><TabItem Header="TabItem3" ><Rectangle Fill="{DynamicResource WarningSolidColorBrush}"/></TabItem></TabControl></UniformGrid>

Nuget Install-Package WPFDevelopers.Minimal

ca9cbeac349065f1e3af3dcecdcd172a.gif

[1][2]

参考资料

[1]

GitHub: https://github.com/WPFDevelopersOrg

[2]

Gitee: https://gitee.com/WPFDevelopersOrg

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/285712.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

开发团队测试的难与易

做了多年的研发工程师&#xff0c;在所处的环境中&#xff0c;所接触的开发人员中很少有看重对自己代码进行测试这项工作的。大多研发人员往往是写好了代码运行起来&#xff0c;简单做下测试&#xff0c;甚至不去测试就抛给接口使用者或者质量管理人员。而且理由很充分“没时间…

C语言试题八十八之实现选冒泡排序算法

📃个人主页:个人主页 🔥系列专栏:C语言试题200例目录 💬推荐一款刷算法、笔试、面经、拿大公司offer神器 👉 点击跳转进入网站 ✅作者简介:大家好,我是码莎拉蒂,CSDN博客专家(全站排名Top 50),阿里云博客专家、51CTO博客专家、华为云享专家 1、题目 C语言实现冒…

两个数值交换位置

2019独角兽企业重金招聘Python工程师标准>>> 先说非计算机专业都能理解的。 int a 10; int b 20; 方法一&#xff1a; int c a; a b; b c; System.out.println("a"a",b"b); 方法二&#xff1a; a a b; b a - b; a a - b; System.out…

教你如何在Android 6.0上创建系统悬浮窗

郭霖大神的文章:http://mp.weixin.qq.com/s?__bizMzA5MzI3NjE2MA&mid2650235949&idx1&sn0f7eded67f834d38b02f8872768cb68a&scene0#wechat_redirect今天周二&#xff0c;又该跟大家分享由我执笔的文章了。从之前我写的deep links、通知栏微技巧这两篇文章中&a…

【CC精品教程】任务三:CC刺像控点,提交空三,新建重建项目(三维格网、三维点云、DOM和DSM)

《无人机航空摄影测量精品教程》合集目录(Pix4d、CC、EPS、PhotoScan、Inpho) 【CC精品教程】任务一:CC新建工程、添加照片、相机参数设置、选择坐标系统 【CC精品教程】任务二:导入像控点、差分POS,空三平差权重设置,提交自由空三 主要任务是准确的刺像控点,提交空三,…

官宣.NET 7 预览版5

点击上方蓝字关注我们&#xff08;本文阅读时间&#xff1a;12分钟)今天我们发布了 .NET 7 预览版 5。.NET 7 的这个预览版包括对通用数学的改进&#xff0c;方便了 API 作者&#xff0c;使其更轻松&#xff0c;一个新的 ML.NET 文本分类 API&#xff0c;增加了最先进的深度学习…

[转]Android产品研发(十九)

转载请标明出处&#xff1a;一片枫叶的专栏 上一篇文章中我们讲解了webview中问题集锦&#xff0c;讲解了webview的性能优化、webview种入Cookie信息、activity退出的时候清除webview信息报错、如何通过java代码和js代码相互交互、webview如何下载文件以及腾讯的X5浏览服务等知…

C语言试题八十九之实现插入排序算法

📃个人主页:个人主页 🔥系列专栏:C语言试题200例目录 💬推荐一款刷算法、笔试、面经、拿大公司offer神器 👉 点击跳转进入网站 ✅作者简介:大家好,我是码莎拉蒂,CSDN博客专家(全站排名Top 50),阿里云博客专家、51CTO博客专家、华为云享专家 1、题目 C语言实现现…

【CC精品教程】ContextCapture 10.17安装教程(附CC10.17安装包下载)

《无人机航空摄影测量精品教程》合集目录(Pix4d、CC、EPS、PhotoScan、Inpho) CC10.17相比之前的版本有了好的新的功能和优点,在倾斜摄影测量中有了更多的优势,精度和运行速度有了很大的提升。本文讲解CC的安装,附CC10.17安装包下载,是您航测倾斜摄影测量的入门必备。 文…

centos7 kickstart 使用小结

1、添加参数使网卡名称变为eth 1bootloader --locationmbr --append"net.ifnames0 biosdevname0 rhgb quiet" 2、psize使用说明&#xff1a;修改vg PE16m 默认4m 支持256G磁盘&#xff0c;适当的调整pesize,可以更多的使用磁盘空间 1volgroup Vol1--pesize16384 pv.…

IOS-网络(文件上传)

1 //2 // ViewController.m3 // IOS_0206_文件上传4 //5 // Created by ma c on 16/2/6.6 // Copyright © 2016年 博文科技. All rights reserved.7 //8 9 #import "ViewController.h"10 #define BWFileBoundary "----------BowenKeJi"11 #define…

mac SecureCRT设置

参考&#xff1a; http://www.2cto.com/os/201407/320292.html SecureCRT 设置 1&#xff09;每次登陆都要输入密码&#xff1a; Global Option -> General 取消&#xff1a;Use Keychain前面的勾 2&#xff09;Logon Actions Logon Actions很强大&#xff0c;和python里…

【微服务专题之】.Net6下集成消息队列上-RabbitMQ

微信公众号&#xff1a;趣编程ACE关注可了解更多的.NET日常实战开发技巧&#xff0c;如需源码 请公众号后台留言 源码;[如果觉得本公众号对您有帮助&#xff0c;欢迎关注].Net中RabbitMQ的使用超清观看视频哦~官网链接RabbitMQ代码演示-详细见代码注释&#xff0c;操作看上文视…

[转]总结:Apache/Tomcat/JBOSS/Jetty/Nginx区别 .

总结&#xff1a;Apache/Tomcat/JBOSS/Nginx区别 . 1、Apache是Web服务器&#xff0c;Tomcat是应用&#xff08;Java&#xff09;服务器。Tomcat在中小型系统和并发访问用户不是很多的场合下被普遍使用。Apache支持静态页&#xff0c;Tomcat支持动态的。 2、Jetty:Tomcat内核作…

华为云GaussDB,11.11让企业无后顾之忧

每年11.11大促对于数据库而言都是一场生死考验&#xff0c;如何保障系统的稳定可靠&#xff0c;如何平稳度过业务流量洪峰期&#xff0c;如何高效扩容&#xff0c;成为每个参与活动客户的一大痛点。本文将通过5个常见的大促问题及分析&#xff0c;看看华为云GaussDB是如何解决这…

【CC精品教程】ContextCapture(CC)集群处理环境部署图文教程

《无人机航空摄影测量精品教程》合集目录(Pix4d、CC、EPS、PhotoScan、Inpho) 鉴于CC其三维构建运算的本质,海量数据的解析运算会使用大量的计算机资源,而再好的单台计算机也无法胜过多台计算机的并行运算能力,故而借助局域网内多台计算机设备进行三维构建运算,可以节省大…

Linux-PAM PAM-MySQL的总结

1、理论知识 1.1、PAM模块 1.1.1、PAM的介绍 Pluggable Authentication Modules简称PAM&#xff0c;是一个微缩的可插入认证模块&#xff08;PAM is an acronym for Pluggable Authentication Modules&#xff09; 1.1.2、PAM的结构 1)模块层(PAM服务模块) - PAM结构最底层 作用…

ubuntu下配置jdk(离线压缩包方式)

2019独角兽企业重金招聘Python工程师标准>>> 1&#xff0c;下载jdk压缩包 2、解压后得到名字为jdk1.7.0_21的文件夹&#xff0c;将其复制到 /usr/lib/jvm下&#xff08;需要新建jvm文件夹&#xff09;。3、配置jdk环境变量&#xff1a;在启动终端并输入 gedit /e…

【PhotoScan精品教程】PhotoScan简介、安装教程(附PhotoScan1.4.5安装包下载)

《无人机航空摄影测量精品教程》合集目录(Pix4d、CC、EPS、PhotoScan、Inpho) PhotoScan在无人机航空摄影测量空三运算中,具有运行速度快、精度高等特点。PhotoScan空三运算的结果可以导入CC等进行模型构建。【PhotoScan精品教程】讲解利用PhotoScan软件进行航测内业空三运算…

利用JS脚本快速删除百度网盘同一目录下的不需要文件(可以参考这个方法删除重复文件)

比如百度网盘某目录下存有如下文件&#xff1a; 要求&#xff1a;将如上图文件目录下的文件&#xff0c;每个月只保留最后&#xff08;新&#xff09;一个&#xff08;根据文件名中包含的日期&#xff09;&#xff0c;其它删除。 比如7月份有3个文件&#xff0c;只保留2019-07-…