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
实现下面的效果
1)TabControl
来实现动画;
TabControl
分为横向和纵向;横向
Border
设置RenderTransform
的ScaleTransform.ScaleY="1"
,动画控制ScaleTransform.ScaleX
从0
到1
;纵向
Border
设置RenderTransform
的ScaleTransform.ScaleX="1"
,动画控制ScaleTransform.ScaleY
从0
到1
;
<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
[1][2]
参考资料
[1]
GitHub: https://github.com/WPFDevelopersOrg
[2]
Gitee: https://gitee.com/WPFDevelopersOrg
WPF 基础控件之 TabControl样式相关推荐
- WPF 基础控件之 GroupBox样式
其他基础控件 1.Window 2.Button 3.CheckBox 4.ComboBox 5.DataGrid 6.DatePicker 7.Expander GroupBox控件修改Style需 ...
- WPF 基础控件之 ToggleButton 样式
其他基础控件 1.Window 2.Button 3.CheckBox 4.ComboBox 5.DataGrid 6.DatePicker 7.Expander 8.GroupBox 9.ListB ...
- WPF 基础控件之Window样式
WPF开发者QQ群: 340500857 由于微信群人数太多入群请添加小编微信号 yanjinhuawechat 或 W_Feng_aiQ 邀请入群 需备注WPF开发者 PS:有更好的方式欢迎推荐. ...
- WPF 基础控件之 DatePicker 样式
此群已满340500857 ,请加新群458041663 由于微信群人数太多入群请添加小编微信号 yanjinhuawechat 或 W_Feng_aiQ 邀请入群 需备注WPF开发者 PS:有更好 ...
- WPF 基础控件之 DataGrid 样式
此群已满340500857 ,请加新群458041663 由于微信群人数太多入群请添加小编微信号 yanjinhuawechat 或 W_Feng_aiQ 邀请入群 需备注WPF开发者 PS:有更好 ...
- WPF 基础控件之CheckBox样式
WPF开发者QQ群:340500857 由于微信群人数太多入群请添加小编微信号 yanjinhuawechat 或 W_Feng_aiQ 邀请入群 需备注WPF开发者 PS:有更好的方式欢迎推荐. ...
- WPF DataGrid控件样式
WPF DataGrid控件样式 <DataGrid ItemsSource="{Binding ProductsList}" AutoGenerateColumns=&qu ...
- WPF Expander控件简单样式
WPF Expander控件简单样式 样式代码: <Style x:Key="ExpanderStyle1" TargetType="{x:Type Expande ...
- WPF开源控件扩展库 - MaterialDesignExtensions
WPF开源控件扩展库 - MaterialDesignExtensions MaterialDesignExtensions仓库截图 logo Material Design Extensions 在 ...
最新文章
- Java项目:在线水果商城系统(java+JSP+Spring+SpringMVC +MyBatis+html+mysql)
- Java方向如何准备BAT技术面试答案
- python工程师薪资坑吗-python能到什么程度
- 使用python和树莓派实现远程监控
- python函数名第一类方法、f-string格式化、迭代器及递归函数
- EasyNVR摄像机网页无插件直播方案H5前端构建之:关于接口调用常见的一些问题(401 Unauthorized)...
- 洛谷P4841 城市规划(多项式求逆)
- 计算机网络中 子网掩码的算法,[网络天地]子网掩码快速算法(转载)
- java 内部thread_Java代码质量改进之:使用ThreadLocal维护线程内部变量
- Docker核心组件的关系
- 用户收货地址h5页面_如何实现H5可视化编辑器的实时预览和真机扫码预览功能?...
- anaconda 安装包 超时_vs2010nuget安装包时 操作超时
- mp3文件修复软件 linux,mp3音乐文件损坏修复软件 MP3 Repair Tool
- oppo(不root)手机查看万能钥匙破解的wifi密码实例
- 空间怎么不能设置html,空间首页登陆 登陆QQ空间怎么将主页设置为首页?
- 【FPGA】DS18B20数字温度传感器实验
- 【图像处理】双线性插值法扩展图像像素及其代码实现(亚像素)
- 2017cad光标大小怎么调_AutoCAD 2010如何调整光标的大小?调整光标大小的方法
- 深入理解JVM(三)——JVM之判断对象是否存活(引用计数算法、可达性分析算法,最终判定),Eclipse设置GC日志输出,引用
- 纯CSS制作3D动态相册【流星雨3D旋转相册】HTML+CSS+JavaScriptHTML5七夕情人节表白网页制作