WPF模拟Office2010文件菜单的TabControl模板
来源:互联网 发布:windows官网镜像 编辑:程序博客网 时间:2024/05/16 01:14
原文转载:http://my.oschina.net/linuxred/blog/93828
近日项目使用TabControl ,希望好看一下,从网上搜到上面那篇博客,仿Office样式,很好看,但原博主代码放的比较抽象,调试了半天,在自己机器上调通之后,Share一份给大家~~~~~~
<Window x:Class="XXX.Dialog.PublishDialog" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="380" Width="600" Icon="/DMS;component/Resources/logo.png" ResizeMode="NoResize" Title="发布项目" Background="White"> <Window.Resources> <ControlTemplate x:Key="OfficeTabControl" TargetType="{x:Type TabControl}"> <Grid> <VisualStateManager.VisualStateGroups> <VisualStateGroup Name="SelectionStates"> <VisualState Name="Selected"> <Storyboard> <DoubleAnimation Storyboard.TargetName="buttonBackgroundShape" Storyboard.TargetProperty="Opacity" To="0" Duration="0"/> </Storyboard> </VisualState> <VisualState Name="Unselected"> <Storyboard> <DoubleAnimation Storyboard.TargetName="buttonBackgroundShape" Storyboard.TargetProperty="Opacity" To="1" Duration="0"/> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Grid.ColumnDefinitions> <ColumnDefinition Width="160" /> <ColumnDefinition/> </Grid.ColumnDefinitions> <Border Name="buttonBackgroundShape" Background="#FFF3EBEB" Grid.Column="0" BorderBrush="LightGray" BorderThickness="0.5" SnapsToDevicePixels="True" /> <StackPanel IsItemsHost="True" Grid.Column="0" Margin="0,0,-1,0" SnapsToDevicePixels="True" /> <ContentPresenter Content="{TemplateBinding SelectedContent}" Grid.Column="1" Margin="5,0,0,0" /> </Grid> </ControlTemplate> <Style x:Key="OfficeTabControlItemStyle" TargetType="{x:Type TabItem}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type TabItem}"> <Grid SnapsToDevicePixels="True"> <VisualStateManager.VisualStateGroups> <VisualStateGroup Name="CommonStates"> <VisualState Name="MouseOver"> <Storyboard> <DoubleAnimation Storyboard.TargetName="hoverShape" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:.1"/> </Storyboard> </VisualState> <VisualState Name="Normal"> <Storyboard> <DoubleAnimation Storyboard.TargetName="hoverShape" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:.1"/> </Storyboard> </VisualState> </VisualStateGroup> <VisualStateGroup Name="SelectionStates"> <VisualState Name="Selected"> <Storyboard> <DoubleAnimation Storyboard.TargetName="buttonShape" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:.3"/> <DoubleAnimation Storyboard.TargetName="buttonShape" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:.3"/> <DoubleAnimation Storyboard.TargetName="hoverShape" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:.1"/> <ColorAnimation Storyboard.TargetName="buttonText" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" To="White" Duration="0:0:.1" /> </Storyboard> </VisualState> <VisualState Name="Unselected"> <Storyboard> <DoubleAnimation Storyboard.TargetName="buttonShape" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:.1"/> <DoubleAnimation Storyboard.TargetName="hoverShape" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:.1"/> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Border x:Name="buttonShape" Opacity="0" BorderBrush="#FF0343A6" BorderThickness="0,2" Height="40" SnapsToDevicePixels="True"> <Path Data="M214,108 L346,108 346.125,118.125 337.75,126.125 346.375,134 346.375,143.875 214.25,144.25 z" SnapsToDevicePixels="True" Stretch="Fill" Height="40"> <Path.Fill> <RadialGradientBrush GradientOrigin="0.2,0.5" RadiusX="0.8" RadiusY="0.8"> <GradientStop Color="#FF5FA3F6" Offset="0" /> <GradientStop Color="#FF0C55B9" Offset="1" /> </RadialGradientBrush> </Path.Fill> </Path> </Border> <Border x:Name="hoverShape" Height="40" Margin="0,0,1,0" SnapsToDevicePixels="True" BorderThickness="0,0,1,0" BorderBrush="LightGray"> <Border BorderBrush="#FFA1B7EA" BorderThickness="0,1" Background="#FFE5EEF9" Height="40" SnapsToDevicePixels="True" /> </Border> <ContentPresenter x:Name="buttonText" Margin="15,0,5,0" TextBlock.FontFamily="Calibri" TextBlock.FontSize="12pt" TextBlock.Foreground="Black" Content="{TemplateBinding Header}" VerticalAlignment="Center"/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </Window.Resources> <Grid> <TabControl Margin="0" Template="{StaticResource OfficeTabControl}" > <TabItem Header="发布路径" IsSelected="True" Style="{DynamicResource OfficeTabControlItemStyle}"> <TextBlock>Info content</TextBlock> </TabItem> <TabItem Header="配置用户" Style="{DynamicResource OfficeTabControlItemStyle}"> <TextBlock>Info content</TextBlock> </TabItem> <TabItem Header="发布项目" Style="{DynamicResource OfficeTabControlItemStyle}"> <TextBlock>Info content</TextBlock> </TabItem> </TabControl> </Grid></Window>
1 0
- WPF模拟Office2010文件菜单的TabControl模板
- WPF模拟Office2010文件菜单的TabControl模板
- WPF 模拟迅雷TabControl界面
- TabControl的菜单
- WPF的TabControl 纵向显示
- WPF中的菜单模板
- WPF中的菜单模板
- WPF:TabItem的Header拉伸的TabControl
- WPF控件TabControl和TabItem原模板分析
- WPF TabControl 美化
- WPF TabControl 样式
- 【WPF收藏】隐藏TabControl标签(按钮)的方法(Hide the TabStrip of a TabControl)
- From Dr.WPF 的Tabcontrol的MVVM性能问题
- 为WPF中TabControl的TabItem添加图片
- WPF 中关于TabControl选项卡中UserControl的问题
- C#的TabControl模拟IE7程序事例,带关闭功能
- WPF TabControl控件禁止切换
- Caliburn.Micro with WPF TabControl
- Boost for Mac安装
- Oracle redo与undo浅析
- maven+jetty+spring的jndi配置
- 使用三元运算符判断奇偶数
- SpringMVC_参数绑定2
- WPF模拟Office2010文件菜单的TabControl模板
- Linux-top命令详解
- Android 异常捕获并重启
- ORACLE12C新特性之在线迁移活跃的数据文件
- 在网页中自带字体的方法
- 性能指标概述
- 不用 * 实现乘法
- SVN更新冲突解释
- App Store审核真能加速么?怎么做到的?