WPF TabControl Styles
WPF TabControl Styles
水平使用的TabControl
效果:
样式资源
<!-- 顶部TabControl控件样式 --><SolidColorBrush x:Key="TabItem.Static.Background" Color="White"/><SolidColorBrush x:Key="TabItem.Static.Border" Color="#ACACAC"/><SolidColorBrush x:Key="TabItem.MouseOver.Border" Color="#7EB4EA"/><SolidColorBrush x:Key="TabItem.Disabled.Background" Color="#F0F0F0"/><SolidColorBrush x:Key="TabItem.Disabled.Border" Color="#D9D9D9"/><SolidColorBrush x:Key="TabItem.Selected.Border" Color="#ACACAC"/><SolidColorBrush x:Key="TabItem.Selected.Background" Color="#FFFFFF"/><Style x:Key="TabItem.Style.TopTabStripPlacement" TargetType="{x:Type TabItem}"><Setter Property="Foreground" Value="Black"/><Setter Property="Background" Value="{StaticResource TabItem.Static.Background}"/><Setter Property="BorderBrush" Value="{StaticResource TabItem.Static.Border}"/><Setter Property="Margin" Value="0"/><Setter Property="Padding" Value="0,8,0,8"/><Setter Property="HorizontalContentAlignment" Value="Stretch"/><Setter Property="VerticalContentAlignment" Value="Stretch"/><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type TabItem}"><Border Padding="0 0 20 0" ><Grid x:Name="templateRoot" SnapsToDevicePixels="true" ><Border Background="{TemplateBinding Background}"></Border><ContentPresenter x:Name="contentPresenter" ContentSource="Header" Focusable="False"HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" TextBlock.FontSize="12" TextBlock.FontWeight="UltraBlack" TextBlock.FontFamily="幼圆"SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"VerticalAlignment="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/><Grid Height="2" x:Name="bottomLine" VerticalAlignment="Bottom" Background="#498FD7" Visibility="Hidden"></Grid></Grid></Border><ControlTemplate.Triggers><Trigger Property="IsEnabled" Value="false"><Setter Property="Opacity" TargetName="contentPresenter" Value="0.56"/></Trigger><Trigger Property="IsSelected" Value="true"><Setter Property="Panel.ZIndex" Value="1"/><Setter Property="Opacity" TargetName="templateRoot" Value="1"/><Setter Property="Visibility" TargetName="bottomLine" Value="Visible"/><Setter Property="Foreground" Value="#498FD7"/></Trigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter></Style><Style x:Key="TabControl.Style.TopTabStripPlacement" TargetType="{x:Type TabControl}"><Setter Property="Padding" Value="0"/><Setter Property="HorizontalContentAlignment" Value="Center"/><Setter Property="VerticalContentAlignment" Value="Center"/><Setter Property="Background" Value="{StaticResource TabItem.Selected.Background}"/><Setter Property="BorderBrush" Value="{StaticResource TabItem.Selected.Border}"/><Setter Property="BorderThickness" Value="0"/><Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type TabControl}"><Grid x:Name="templateRoot" ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local"><Grid.ColumnDefinitions><ColumnDefinition x:Name="ColumnDefinition0"/><ColumnDefinition x:Name="ColumnDefinition1" Width="0"/></Grid.ColumnDefinitions><Grid.RowDefinitions><RowDefinition x:Name="RowDefinition0" Height="Auto"/><RowDefinition x:Name="RowDefinition2" Height="Auto"/><RowDefinition x:Name="RowDefinition1" Height="*"/></Grid.RowDefinitions><TabPanel x:Name="headerPanel" Grid.Column="0" IsItemsHost="true" Grid.Row="0" KeyboardNavigation.TabIndex="1" Panel.ZIndex="1"/><Grid Grid.Row="1" Background="#A8D3FE" VerticalAlignment="Top" Height="1"></Grid><Border x:Name="contentPanel" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.Column="0" KeyboardNavigation.DirectionalNavigation="Contained" Grid.Row="2" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local"><ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/></Border></Grid><ControlTemplate.Triggers><Trigger Property="IsEnabled" Value="false"><Setter Property="TextElement.Foreground" TargetName="templateRoot" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/></Trigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter></Style>
MainWindow.xaml使用
<Window x:Class="TabControlStyle.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:TabControlStyle"mc:Ignorable="d"Title="MainWindow" Height="450" Width="800"><Grid><Border Height="212.493" VerticalAlignment="Center" ><TabControl Width="441.81" HorizontalAlignment="Center" Style="{DynamicResource TabControl.Style.TopTabStripPlacement}"><TabItem Header="检测" Style="{DynamicResource TabItem.Style.TopTabStripPlacement}"><WrapPanel Background="White" Margin="0 5"><Border BorderBrush="#FFD2DDE8" BorderThickness="1" Width="100" Height="150"/></WrapPanel></TabItem><TabItem Header="控制" Style="{DynamicResource TabItem.Style.TopTabStripPlacement}"><Grid Background="#FFE5E5E5"/></TabItem><TabItem Header="日志" Style="{DynamicResource TabItem.Style.TopTabStripPlacement}"><Grid Background="#FFE5E5E5"/></TabItem></TabControl></Border></Grid>
</Window>
积跬步以至千里:) (:一阵没来由的风
WPF TabControl Styles相关推荐
- WPF TabControl控件示例
WPF TabControl控件示例 运行效果: 主窗体XAML代码: <Window x:Class="WPF0417.MainWindow"xmlns="htt ...
- WPF TabControl Unload俩次的解决方案
原文:WPF TabControl Unload俩次的解决方案 WPF中,有些控件会多次触发Unload,有点莫名其妙~ Unload的多次触发 TabControl的内容,我是这么设置的: 在Tab ...
- WPF TabControl 美化
转载来源:http://www.cnblogs.com/xling/p/3595602.html WPF TabControl 美化 文章很详细的说明了怎么做的美化 只是在学习过程中没有代码下载让人 ...
- C# WPF TabControl控件用法详解
概述 TabControl我之前有讲过一节,内容详见:C# WPF TabControl用法指南(精品),上节主要讲解了tabcontrol控件的左右翻页,以及页面筛选,以及数据绑定等内容,这节内容继 ...
- WPF TabControl 数据绑定
WPF TabControl in Binding's world 首先,TabControl是间接继承自ItemControl的控件,因此可以像ItemControl那样自如的使用. 自此,我们知道 ...
- html tabcontrol模板,WPF TabControl模板+ ItemContainerStyle
我正在尝试创建一个基本上看起来像中心顶部的按钮和下面显示tabitem内容的内容面板上的按钮控制样式.WPF TabControl模板+ ItemContainerStyle 我对模板有点新,但到目前 ...
- WPF TabControl 隐藏标头
1. 将每个 TabItem 的 Visibility 属性设置为 Visibility.Collapsed 即可隐藏标头 <TabItem Visibility="Collapsed ...
- WPF TabControl美化
实现效果 XMAL样式 <Window.Resources><!-- TabItem的样式 --><Style TargetType="{x:Type TabI ...
- WPF TabControl的好看样式
注意:以下两种样式暂时只支持TabStripPlacement="Top",也就是标签在上方的效果 第一种: 效果如图: 样式代码: <Style x:Key="T ...
最新文章
- Python常用包的使用
- SpringBoot是如何解析HTTP参数的?
- 利物浦大学comp313课程第一节课
- 46. Permutations 排列数
- navicat工具查看MySQL数据库_表占用容量_占用空间是多少MB---Linux工作笔记048
- ASP.NET Core 2.1 源码学习之 Options[3]:IOptionsMonitor 【转】
- opkg-utils的PKGBUILD文件,参考自OE的opkg-utils_git.bb
- 汉王数据导入java环境,怎样把u盆内容导入汉王门禁考勤管理软件
- html---标题居中,背景图片
- Android FFmpeg视频播放器一解封装
- mysql支付账单怎么设计_订单与支付设计
- 58欧氏空间05——对称变换和对称矩阵、实对称矩阵的标准形、正交相似
- BZOJ1050 旅行comf(kruskal)
- mysql更改数据库登录密码失败;Access denied for user 'root'@'localhost;mysqladmin: connect to server at 'localhos
- 我的留英日记[转载]
- STM32 ADC 单次模式、连续模式、扫描模式
- ffmpeg 连接抖音三个视频,做电脑桌面
- 4天狂销20万盒,GMV超5620万,应季爆品有哪些营销关键词?
- Ardunio下实现STM32的串口通信及其与Stduino的区别
- SwiftUI 精品项目之完整MOOC幕课iOS项目 含服务端 轮播欢迎页面(教程含源码)
热门文章
- 如何应用Dynamo创建几何形体?
- A12X性能赶上Intel,苹果放弃Intel还差点什么?
- 2021-2022-2 ACM集训队每周程序设计竞赛(1) - 问题 A: 排火车 - 题解
- java解压zip与rar
- 05 | 访问控制:如何选取一个合适的数据保护方案?
- 5 steps to land a data science job in just 6 months :)
- [python][转载]ubuntu上matplotlib显示中文
- XnView v2.25
- 地推里的t1结算啥意思
- DEMO | AI预测股票短期走势「AI工程论」