TabControl增加TabStripPlacement设置

调整原有的TabControl样式,使设置TabStripPlacement参数生效
This commit is contained in:
眾尋 2019-04-17 21:05:03 +08:00
parent 2f5c21fc62
commit 0407b83b4d
2 changed files with 94 additions and 1 deletions

View File

@ -41,6 +41,33 @@
<Setter Property="TextElement.Foreground" Value="{DynamicResource PrimaryBrush}" TargetName="contentPresenter"/>
<Setter Property="BorderThickness" TargetName="mainBorder" Value="0,0,0,3"/>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true"/>
<Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType=TabControl}}" Value="Left"/>
</MultiDataTrigger.Conditions>
<Setter Property="Panel.ZIndex" Value="1"/>
<Setter Property="TextElement.Foreground" Value="{DynamicResource PrimaryBrush}" TargetName="contentPresenter"/>
<Setter Property="BorderThickness" TargetName="mainBorder" Value="0,0,3,0"/>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true"/>
<Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType=TabControl}}" Value="Bottom"/>
</MultiDataTrigger.Conditions>
<Setter Property="Panel.ZIndex" Value="1"/>
<Setter Property="TextElement.Foreground" Value="{DynamicResource PrimaryBrush}" TargetName="contentPresenter"/>
<Setter Property="BorderThickness" TargetName="mainBorder" Value="0,3,0,0"/>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true"/>
<Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType=TabControl}}" Value="Right"/>
</MultiDataTrigger.Conditions>
<Setter Property="Panel.ZIndex" Value="1"/>
<Setter Property="TextElement.Foreground" Value="{DynamicResource PrimaryBrush}" TargetName="contentPresenter"/>
<Setter Property="BorderThickness" TargetName="mainBorder" Value="3,0,0,0"/>
</MultiDataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
@ -72,6 +99,37 @@
</Border>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="TabStripPlacement" Value="Bottom">
<Setter TargetName="RowDefinition0" Property="Height" Value="*"/>
<Setter TargetName="RowDefinition1" Property="Height" Value="Auto"/>
<Setter TargetName="headerPanel" Property="Grid.Row" Value="1"/>
<Setter TargetName="contentPanel" Property="Grid.Row" Value="0"/>
<Setter TargetName="contentPanel" Property="BorderThickness" Value="0,0,0,1"/>
</Trigger>
<Trigger Property="TabStripPlacement" Value="Left">
<Setter TargetName="RowDefinition0" Property="Height" Value="*" />
<Setter TargetName="RowDefinition1" Property="Height" Value="0" />
<Setter TargetName="ColumnDefinition0" Property="Width" Value="Auto" />
<Setter TargetName="ColumnDefinition1" Property="Width" Value="*" />
<Setter TargetName="headerPanel" Property="Grid.Column" Value="0" />
<Setter TargetName="headerPanel" Property="Grid.Row" Value="0" />
<Setter TargetName="contentPanel" Property="Grid.Column" Value="1" />
<Setter TargetName="contentPanel" Property="Grid.Row" Value="0" />
<Setter TargetName="contentPanel" Property="BorderThickness" Value="1,0,0,0"/>
</Trigger>
<Trigger Property="TabStripPlacement" Value="Right">
<Setter TargetName="RowDefinition0" Property="Height" Value="*" />
<Setter TargetName="RowDefinition1" Property="Height" Value="0" />
<Setter TargetName="ColumnDefinition0" Property="Width" Value="*" />
<Setter TargetName="ColumnDefinition1" Property="Width" Value="Auto" />
<Setter TargetName="headerPanel" Property="Grid.Column" Value="1" />
<Setter TargetName="headerPanel" Property="Grid.Row" Value="0" />
<Setter TargetName="contentPanel" Property="Grid.Column" Value="0" />
<Setter TargetName="contentPanel" Property="Grid.Row" Value="0" />
<Setter TargetName="contentPanel" Property="BorderThickness" Value="0,0,0,1"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>

View File

@ -142,6 +142,41 @@
</Border>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="TabStripPlacement" Value="Bottom">
<Setter TargetName="RowDefinition0" Property="Height" Value="*"/>
<Setter TargetName="RowDefinition1" Property="Height" Value="Auto"/>
<Setter TargetName="headerPanel" Property="Grid.Row" Value="1"/>
<Setter TargetName="contentPanel" Property="Grid.Row" Value="0"/>
<Setter TargetName="contentPanel" Property="BorderThickness" Value="0,0,0,1"/>
</Trigger>
<Trigger Property="TabStripPlacement" Value="Left">
<Setter TargetName="RowDefinition0" Property="Height" Value="*" />
<Setter TargetName="RowDefinition1" Property="Height" Value="0" />
<Setter TargetName="ColumnDefinition0" Property="Width" Value="Auto" />
<Setter TargetName="ColumnDefinition1" Property="Width" Value="*" />
<Setter TargetName="headerPanel" Property="Grid.Column" Value="0" />
<Setter TargetName="headerPanel" Property="Grid.Row" Value="0" />
<Setter TargetName="contentPanel" Property="Grid.Column" Value="1" />
<Setter TargetName="contentPanel" Property="Grid.Row" Value="0" />
<Setter TargetName="contentPanel" Property="BorderThickness" Value="1,0,0,0"/>
<Setter TargetName="headerPanel" Property="Rows" Value="0"/>
<Setter TargetName="headerPanel" Property="Columns" Value="1"/>
</Trigger>
<Trigger Property="TabStripPlacement" Value="Right">
<Setter TargetName="RowDefinition0" Property="Height" Value="*" />
<Setter TargetName="RowDefinition1" Property="Height" Value="0" />
<Setter TargetName="ColumnDefinition0" Property="Width" Value="*" />
<Setter TargetName="ColumnDefinition1" Property="Width" Value="Auto" />
<Setter TargetName="contentPanel" Property="Grid.Column" Value="0" />
<Setter TargetName="contentPanel" Property="Grid.Row" Value="0" />
<Setter TargetName="contentPanel" Property="BorderThickness" Value="0,0,0,1"/>
<Setter TargetName="headerPanel" Property="Grid.Column" Value="1" />
<Setter TargetName="headerPanel" Property="Grid.Row" Value="0" />
<Setter TargetName="headerPanel" Property="Rows" Value="0"/>
<Setter TargetName="headerPanel" Property="Columns" Value="1"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
@ -196,7 +231,7 @@
<Border x:Name="contentPanel" Margin="0,6,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}" Background="{TemplateBinding Background}" Grid.Column="0" KeyboardNavigation.DirectionalNavigation="Contained" Grid.Row="1" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local">
<ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>