TabControl选项卡
<pre><code class="language-csharp">&lt;TabControl Width=&quot;780&quot; Height=&quot;587&quot; Style=&quot;{DynamicResource TabControlStyle}&quot;&gt;
&lt;TabItem Header=&quot;Home&quot; Style=&quot;{DynamicResource TabItemStyle}&quot; &gt;
&lt;/TabItem&gt;
&lt;TabItem Header=&quot;Home1&quot; Style=&quot;{DynamicResource TabItemStyle}&quot;&gt;
&lt;/TabItem&gt;
&lt;TabItem Header=&quot;Home2&quot; Style=&quot;{DynamicResource TabItemStyle}&quot;&gt;
&lt;/TabItem&gt;
&lt;/TabControl&gt;
&lt;Application.Resources&gt;
&lt;ResourceDictionary&gt;
&lt;ResourceDictionary.MergedDictionaries&gt;
&lt;!--&lt;ResourceDictionary Source=&quot;Style/ColorStyle.xaml&quot;&gt;&lt;/ResourceDictionary&gt;--&gt;
&lt;ResourceDictionary Source=&quot;Style/ComBoxStyle.xaml&quot;&gt;&lt;/ResourceDictionary&gt;
&lt;/ResourceDictionary.MergedDictionaries&gt;
&lt;/ResourceDictionary&gt;
&lt;/Application.Resources&gt;</code></pre>
<h3>模版</h3>
<pre><code class="language-csharp">&lt;ResourceDictionary xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;&gt;
&lt;LinearGradientBrush x:Key=&quot;TabItem.Selected.BordernCjh&quot; StartPoint=&quot;0,0&quot; EndPoint=&quot;0,1&quot;&gt;
&lt;GradientStop Color=&quot;#FFE8A6&quot; Offset=&quot;0.07&quot; /&gt;
&lt;GradientStop Color=&quot;#FFFAEA&quot; Offset=&quot;0.1&quot; /&gt;
&lt;GradientStop Color=&quot;#FFFAEA&quot; Offset=&quot;0.4&quot; /&gt;
&lt;GradientStop Color=&quot;#FFE8A6&quot; Offset=&quot;0.5&quot; /&gt;
&lt;/LinearGradientBrush&gt;
&lt;SolidColorBrush x:Key=&quot;PrimaryBlueColor&quot; Color=&quot;#348EF6&quot;/&gt;
&lt;SolidColorBrush x:Key=&quot;SecundaryBlueColor&quot; Color=&quot;#EFF2EF&quot;/&gt;
&lt;SolidColorBrush x:Key=&quot;PrimaryTextColor&quot; Color=&quot;#FFFFFF&quot;/&gt;
&lt;SolidColorBrush x:Key=&quot;SecundaryTextColor&quot; Color=&quot;#BBC1D1&quot;/&gt;
&lt;!--start Style--&gt;
&lt;!--start tabItem Style
Foreground=&quot;{DynamicResource SecundaryTextColor}&quot;
--&gt;
&lt;Style x:Key=&quot;TabItemStyle&quot; TargetType=&quot;TabItem&quot;&gt;
&lt;Setter Property=&quot;Background&quot; Value=&quot;Transparent&quot;/&gt;
&lt;Setter Property=&quot;Foreground&quot; Value=&quot;{DynamicResource SecundaryTextColor}&quot;/&gt;
&lt;!--&lt;Setter Property=&quot;FontWeight&quot; Value=&quot;Bold&quot;/&gt;--&gt;
&lt;Setter Property=&quot;BorderThickness&quot; Value=&quot;0&quot;/&gt;
&lt;Setter Property=&quot;Margin&quot; Value=&quot;0 0 5 0&quot;/&gt;
&lt;Setter Property=&quot;Width&quot; Value=&quot;100&quot;/&gt;
&lt;Setter Property=&quot;Padding&quot; Value=&quot;10 10&quot;/&gt;
&lt;Setter Property=&quot;VerticalAlignment&quot; Value=&quot;Top&quot;/&gt;
&lt;Setter Property=&quot;HorizontalAlignment&quot; Value=&quot;Left&quot;/&gt;
&lt;Setter Property=&quot;Template&quot;&gt;
&lt;Setter.Value&gt;
&lt;ControlTemplate TargetType=&quot;TabItem&quot;&gt;
&lt;Grid SnapsToDevicePixels=&quot;True&quot;&gt;
&lt;Border CornerRadius=&quot;5&quot;
Background=&quot;{TemplateBinding Background}&quot;
BorderThickness=&quot;{TemplateBinding BorderThickness}&quot;
BorderBrush=&quot;{TemplateBinding BorderBrush}&quot;
Margin=&quot;{TemplateBinding Margin}&quot;
/&gt;
&lt;ContentPresenter HorizontalAlignment=&quot;Center&quot;
VerticalAlignment=&quot;{TemplateBinding VerticalAlignment}&quot;
SnapsToDevicePixels=&quot;True&quot;
RecognizesAccessKey=&quot;True&quot;
Margin=&quot;{TemplateBinding Padding}&quot;
ContentSource=&quot;Header&quot;
Focusable=&quot;True&quot;/&gt;
&lt;/Grid&gt;
&lt;ControlTemplate.Triggers&gt;
&lt;Trigger Property=&quot;IsMouseOver&quot; Value=&quot;True&quot;&gt;
&lt;Setter Property=&quot;Background&quot; Value=&quot;{DynamicResource SecundaryBlueColor}&quot;/&gt;
&lt;Setter Property=&quot;Foreground&quot; Value=&quot;{DynamicResource PrimaryBlueColor}&quot;/&gt;
&lt;/Trigger&gt;
&lt;Trigger Property=&quot;IsSelected&quot; Value=&quot;True&quot;&gt;
&lt;Setter Property=&quot;Background&quot; Value=&quot;{DynamicResource PrimaryBlueColor}&quot;/&gt;
&lt;Setter Property=&quot;Foreground&quot; Value=&quot;{DynamicResource SecundaryBlueColor}&quot;/&gt;
&lt;/Trigger&gt;
&lt;/ControlTemplate.Triggers&gt;
&lt;/ControlTemplate&gt;
&lt;/Setter.Value&gt;
&lt;/Setter&gt;
&lt;/Style&gt;
&lt;!--end tabItem Style--&gt;
&lt;!--start tabControl Style--&gt;
&lt;Style x:Key=&quot;TabControlStyle&quot; TargetType=&quot;TabControl&quot;&gt;
&lt;Setter Property=&quot;Background&quot; Value=&quot;{DynamicResource SecundaryBlueColor}&quot;/&gt;
&lt;Setter Property=&quot;BorderThickness&quot; Value=&quot;0&quot;/&gt;
&lt;Setter Property=&quot;BorderBrush&quot; Value=&quot;Transparent&quot;/&gt;
&lt;Setter Property=&quot;Padding&quot; Value=&quot;5&quot;/&gt;
&lt;Setter Property=&quot;VerticalAlignment&quot; Value=&quot;Center&quot;/&gt;
&lt;Setter Property=&quot;HorizontalAlignment&quot; Value=&quot;Center&quot;/&gt;
&lt;Setter Property=&quot;Template&quot;&gt;
&lt;Setter.Value&gt;
&lt;ControlTemplate TargetType=&quot;TabControl&quot;&gt;
&lt;Grid SnapsToDevicePixels=&quot;True&quot;&gt;
&lt;Grid.RowDefinitions&gt;
&lt;RowDefinition Height=&quot;50&quot;/&gt;
&lt;RowDefinition Height=&quot;*&quot;/&gt;
&lt;/Grid.RowDefinitions&gt;
&lt;!--TabPanel 可以设置 HorizontalAlignment 属性改变选项卡的对齐方式--&gt;
&lt;TabPanel Grid.Row=&quot;0&quot;
Background=&quot;Transparent&quot;
IsItemsHost=&quot;True&quot;
/&gt;
&lt;Border Grid.Row=&quot;1&quot;
CornerRadius=&quot;5&quot;
BorderThickness=&quot;{TemplateBinding BorderThickness}&quot;
BorderBrush=&quot;{TemplateBinding BorderBrush}&quot;
Background=&quot;{TemplateBinding Background}&quot;
&gt;
&lt;ContentPresenter ContentSource=&quot;SelectedContent&quot;
SnapsToDevicePixels=&quot;True&quot;
Margin=&quot;{TemplateBinding Padding}&quot;/&gt;
&lt;/Border&gt;
&lt;/Grid&gt;
&lt;/ControlTemplate&gt;
&lt;/Setter.Value&gt;
&lt;/Setter&gt;
&lt;/Style&gt;
&lt;/ResourceDictionary&gt;</code></pre>