码迷,mamicode.com
首页 > 其他好文 > 详细

Templ

时间:2015-11-28 21:28:22      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:

mianWindow

 

<UserControl x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="350" Width="525">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Styles/TabControlStyles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<DockPanel Name="Git">
<Grid DockPanel.Dock="Top">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<!-- Header-->
<TextBlock Grid.Row="0" Height="150" Width="Auto" Text="Git Code Manage Dashboard"
FontSize="30"
Padding="50"
FontWeight="Bold"
Foreground="White"
>
<TextBlock.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#007ACC" Offset="0.39"/>
<GradientStop Color="White" Offset="0.8"/>
</LinearGradientBrush>
</TextBlock.Background>
</TextBlock>
<!-- Body -->
<TabControl Grid.Row="1" Style="{DynamicResource GitTabControlStyle}" Margin="20,10,20,10">
<TabItem Header="Overall" IsSelected="True" Style="{DynamicResource GitTabItemStyle}">
<Grid>
<Button Content="Overall"></Button>
</Grid>
</TabItem>
<TabItem Header="Commits" Style="{DynamicResource GitTabItemStyle}">
<Grid>
<Button Content="Commit"></Button>
</Grid>
</TabItem>
<TabItem Header="Settings" Style="{DynamicResource GitTabItemStyle}">
<Grid>
<Button Content="Setting"></Button>
</Grid>
</TabItem>
</TabControl>
<!-- Foot-->
<Border Grid.Row="2" DockPanel.Dock ="Bottom" Height="20" Width="Auto">
<Border.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#007ACC" Offset="0.39"/>
</LinearGradientBrush>
</Border.Background>
</Border>


</Grid>
</DockPanel>
</UserControl>

 

 

style

 

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="TabControl.HeaderBackGround" Color="#007ACC" />
<SolidColorBrush x:Key="TabControl.ActivedItemHeaderBackground" Color="#FF10a8ab" />
<SolidColorBrush x:Key="TabControl.BodyBackground" Color="White" />
<SolidColorBrush x:Key="TabControl.BorderBrush" Color="Gray" />
<SolidColorBrush x:Key="TabItem.Foreground" Color="#FF9BEDF3" />

<Style x:Key="GitTabControlStyle" TargetType="{x:Type TabControl}" BasedOn="{StaticResource {x:Type TabControl}}">
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabControl}">
<Grid>
<Border Background="{DynamicResource TabControl.BodyBackground}" BorderThickness="1" BorderBrush="{DynamicResource TabControl.BorderBrush}" Margin="-1">
<Border.Effect>
<BlurEffect />
</Border.Effect>
</Border>

<Border BorderBrush="{DynamicResource TabControl.BorderBrush}" BorderThickness="1" ClipToBounds="True" SnapsToDevicePixels="True">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Name="ROW0" Height="30"/>
<RowDefinition Name="ROW1" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Name="COL0" />
<ColumnDefinition Name="COL1" />
</Grid.ColumnDefinitions>

<Border Background="{DynamicResource TabControl.HeaderBackGround}" Name="Mask" />

<Border Grid.Row="0" Grid.Column="0" Padding="10,6" Name="TP">
<TabPanel IsItemsHost="True">
<TabPanel.OpacityMask>
<VisualBrush Visual="{Binding ElementName=Mask}" />
</TabPanel.OpacityMask>
</TabPanel>
</Border>

<Grid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Name="TC">
<Border Name="EB" Margin="-1" BorderThickness="0,0,0,0" BorderBrush="{DynamicResource TabControl.BorderBrush}">
<Border.Effect>
<BlurEffect Radius="5" />
</Border.Effect>
</Border>
<Border>
<ContentPresenter x:Name="PART_SelectedContentHost" Width="Auto"
ContentSource="SelectedContent" Margin="10"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
</Grid>
</Grid>
</Border>
</Grid>

<ControlTemplate.Triggers>
<Trigger Property="TabStripPlacement" Value="Top">
<Setter TargetName="ROW0" Property="Height" Value="auto" />

<Setter TargetName="Mask" Property="Grid.Row" Value="0" />
<Setter TargetName="Mask" Property="Grid.Column" Value="0" />
<Setter TargetName="Mask" Property="Grid.ColumnSpan" Value="2" />
<!--<Setter TargetName="Mask" Property="CornerRadius" Value="10,10,0,0" />-->

<Setter TargetName="TP" Property="Grid.Row" Value="0" />
<Setter TargetName="TP" Property="Grid.Column" Value="0" />
<Setter TargetName="TP" Property="Grid.ColumnSpan" Value="2" />

<Setter TargetName="TC" Property="Grid.Column" Value="0" />
<Setter TargetName="TC" Property="Grid.Row" Value="1" />
<Setter TargetName="TC" Property="Grid.ColumnSpan" Value="2" />

<Setter TargetName="EB" Property="BorderThickness" Value="0,1,0,0" />
</Trigger>
<Trigger Property="TabStripPlacement" Value="Bottom">
<Setter TargetName="ROW1" Property="Height" Value="auto" />

<Setter TargetName="Mask" Property="Grid.Row" Value="1" />
<Setter TargetName="Mask" Property="Grid.Column" Value="0" />
<Setter TargetName="Mask" Property="Grid.ColumnSpan" Value="2" />
<Setter TargetName="Mask" Property="CornerRadius" Value="0,0,10,10" />

<Setter TargetName="TP" Property="Grid.Row" Value="1" />
<Setter TargetName="TP" Property="Grid.Column" Value="0" />
<Setter TargetName="TP" Property="Grid.ColumnSpan" Value="2" />

<Setter TargetName="TC" Property="Grid.Column" Value="0" />
<Setter TargetName="TC" Property="Grid.Row" Value="0" />
<Setter TargetName="TC" Property="Grid.ColumnSpan" Value="2" />

<Setter TargetName="EB" Property="BorderThickness" Value="0,0,0,1" />
</Trigger>
<Trigger Property="TabStripPlacement" Value="Left">
<Setter TargetName="COL0" Property="Width" Value="auto" />

<Setter TargetName="Mask" Property="Grid.Row" Value="0" />
<Setter TargetName="Mask" Property="Grid.Column" Value="0" />
<Setter TargetName="Mask" Property="Grid.RowSpan" Value="2" />
<Setter TargetName="Mask" Property="CornerRadius" Value="10,0,0,10" />

<Setter TargetName="TP" Property="Grid.Row" Value="0" />
<Setter TargetName="TP" Property="Grid.Column" Value="0" />
<Setter TargetName="TP" Property="Grid.RowSpan" Value="2" />

<Setter TargetName="TC" Property="Grid.Column" Value="1" />
<Setter TargetName="TC" Property="Grid.Row" Value="0" />
<Setter TargetName="TC" Property="Grid.RowSpan" Value="2" />

<Setter TargetName="EB" Property="BorderThickness" Value="1,0,0,0" />
</Trigger>
<Trigger Property="TabStripPlacement" Value="Right">
<Setter TargetName="COL1" Property="Width" Value="auto" />

<Setter TargetName="Mask" Property="Grid.Row" Value="0" />
<Setter TargetName="Mask" Property="Grid.Column" Value="1" />
<Setter TargetName="Mask" Property="Grid.RowSpan" Value="2" />
<Setter TargetName="Mask" Property="CornerRadius" Value="0,10,10,0" />

<Setter TargetName="TP" Property="Grid.Row" Value="0" />
<Setter TargetName="TP" Property="Grid.Column" Value="1" />
<Setter TargetName="TP" Property="Grid.RowSpan" Value="2" />

<Setter TargetName="TC" Property="Grid.Column" Value="0" />
<Setter TargetName="TC" Property="Grid.Row" Value="0" />
<Setter TargetName="TC" Property="Grid.RowSpan" Value="2" />

<Setter TargetName="EB" Property="BorderThickness" Value="0,0,1,0" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="GitTabItemStyle" TargetType="{x:Type TabItem}" BasedOn="{StaticResource {x:Type TabItem}}">
<Setter Property="TextBlock.Foreground" Value="{DynamicResource TabItem.Foreground}" />
<Setter Property="TextBlock.FontSize" Value="14" />
<Setter Property="TextBlock.FontWeight" Value="Bold" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}">
<Border x:Name="bbb" SnapsToDevicePixels="True" ClipToBounds="True" CornerRadius="15" >
<ContentPresenter x:Name="contentPresenter"
ContentSource="Header"
Focusable="False"
HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"
Margin="{TemplateBinding Padding}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}">

</ContentPresenter>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="bbb" Property="Background" Value="{DynamicResource TabControl.ActivedItemHeaderBackground}" />
<Setter TargetName="bbb" Property="Padding" Value="3" />
</Trigger>
<Trigger Property="TabStripPlacement" Value="Left">
<Setter Property="LayoutTransform">
<Setter.Value>
<RotateTransform Angle="-90" />
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="TabStripPlacement" Value="Right">
<Setter Property="LayoutTransform">
<Setter.Value>
<RotateTransform Angle="90" />
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

Templ

标签:

原文地址:http://www.cnblogs.com/icebeanseven/p/5003395.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!