- 积分
- 0
- 在线时间
- 13 小时
- 主题
- 2
- 注册时间
- 2015-5-10
- 帖子
- 14
- 最后登录
- 2016-7-2
- 帖子
- 14
- 软币
- 156
- 在线时间
- 13 小时
- 注册时间
- 2015-5-10
|
修改的Tabcontrol控件样式,有关闭按钮,没有后台关闭代码,请指导!
<SolidColorBrush x:Key="BackgroundHighlighted" Color="#54545C" />
<SolidColorBrush x:Key="BorderBrushHighlighted" Color="#6A6A75" />
<SolidColorBrush x:Key="BackgroundSelected" Color="#FF007ACC" />
<SolidColorBrush x:Key="BorderBrushSelected" Color="#1C97EA" />
<SolidColorBrush x:Key="BackgroundNormal" Color="#3F3F46" />
<SolidColorBrush x:Key="BorderBrushNormal" Color="#54545C" />
<SolidColorBrush x:Key="CloseButtonBackgroundHighlighted" Color="#39ADFB" />
<SolidColorBrush x:Key="CloseButtonBackgroundPressed" Color="#084E7D" />
<SolidColorBrush x:Key="CloseButtonStroke" Color="#AAFFFFFF" />
<SolidColorBrush x:Key="CloseButtonStrokeHighlighted" Color="#FFFFFF" />
<Style x:Key="TabControlStyle"
TargetType="{x:Type TabControl}">
<Style.Resources>
<Style TargetType="{x:Type TabItem}">
<Setter Property="FocusVisualStyle"
Value="{x:Null}" />
<Setter Property="Background"
Value="Transparent" />
<Setter Property="Foreground"
Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
<Setter Property="BorderThickness"
Value="0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}">
<Grid Height="30"
Background="{TemplateBinding Background}"
SnapsToDevicePixels="true">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="25" />
</Grid.ColumnDefinitions>
<ContentPresenter Grid.Column="0"
Margin="10,0,10,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
ContentSource="Header" />
<Button Grid.Column="1"
Width="15"
Height="15"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Command="{Binding Path=CloseCommand}"
DockPanel.Dock="Right">
<Button.Style>
<Style TargetType="{x:Type Button}">
<Setter Property="Background"
Value="Transparent" />
<Setter Property="Cursor"
Value="Hand" />
<Setter Property="Focusable"
Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid Background="{TemplateBinding Background}">
<Path x:Name="ButtonPath"
Margin="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="M0,0 L1,1 M0,1 L1,0"
Stretch="Uniform"
Stroke="{DynamicResource CloseButtonStroke}"
StrokeEndLineCap="Flat"
StrokeStartLineCap="Flat"
StrokeThickness="2" />
</Grid>
<ControlTemplate.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=TabItem}}"
Value="false" />
<Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=TabItem}}"
Value="false" />
</MultiDataTrigger.Conditions>
<MultiDataTrigger.Setters>
<Setter Property="Visibility"
Value="Hidden" />
</MultiDataTrigger.Setters>
</MultiDataTrigger>
<Trigger Property="IsEnabled"
Value="False">
<Setter Property="Visibility"
Value="Hidden" />
</Trigger>
<Trigger Property="IsMouseOver"
Value="True">
<Setter Property="Background"
Value="{DynamicResource CloseButtonBackgroundHighlighted}" />
<Setter TargetName="ButtonPath"
Property="Stroke"
Value="{DynamicResource CloseButtonStrokeHighlighted}" />
</Trigger>
<Trigger Property="IsPressed"
Value="true">
<Setter Property="Background"
Value="{DynamicResource CloseButtonBackgroundPressed}" />
<Setter TargetName="ButtonPath"
Property="Stroke"
Value="{DynamicResource CloseButtonStroke}" />
<Setter TargetName="ButtonPath"
Property="Margin"
Value="2.5,2.5,1.5,1.5" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Button.Style>
</Button>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected"
Value="false">
<Setter Property="Background"
Value="Transparent" />
</Trigger>
<Trigger Property="IsMouseOver"
Value="true">
<Setter Property="Background"
Value="{DynamicResource BorderBrushSelected}" />
</Trigger>
<Trigger Property="IsSelected"
Value="true">
<Setter Property="Background"
Value="{DynamicResource BackgroundSelected}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Style.Resources>
</Style>
|
|