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.pswp.cn/news/285712.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/285712.shtml
英文地址,請注明出處:http://en.pswp.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-…