码迷,mamicode.com
首页 > Windows程序 > 详细

WPF常用样式总结

时间:2019-03-23 14:34:19      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:sse   put   auto   Nero   selected   convert   let   mic   tabs   

常用控件样式:

技术图片
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <!-- 文字按钮 -->
    <Style x:Key="stlTxtBtn" TargetType="{x:Type Button}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Border Background="Transparent">
                        <Border x:Name="bd" Background="#1aa4f5" CornerRadius="2" Padding="{TemplateBinding Padding}">
                            <TextBlock x:Name="txt" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5 2 5 2"  Foreground="White" ><InlineUIContainer>
                                            <ContentPresenter />
                                        </InlineUIContainer></TextBlock>
                        </Border>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="bd" Property="Background" Value="#33c4f5"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter TargetName="txt" Property="FontSize" Value="11"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <!-- 文字按钮浅色 -->
    <Style x:Key="stlTxtBtnLight" TargetType="{x:Type Button}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Border Background="Transparent">
                        <Border x:Name="bd" Background="#0cc663" CornerRadius="2" Padding="{TemplateBinding Padding}">
                            <TextBlock x:Name="txt" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5 2 5 2"  Foreground="White" ><InlineUIContainer>
                                            <ContentPresenter />
                                        </InlineUIContainer></TextBlock>
                        </Border>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="bd" Property="Background" Value="#0cb653"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter TargetName="txt" Property="FontSize" Value="11"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <!-- 图片按钮 -->
    <ControlTemplate x:Key="tmplImgBtn" TargetType="{x:Type Button}">
        <Border x:Name="bd" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" CornerRadius="2"  Background="{TemplateBinding Background}" >
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                <Image x:Name="img" Margin="-2 2 3 0"  Width="15" Height="15" VerticalAlignment="Center" Stretch="UniformToFill" Source="{TemplateBinding Tag}" />
                <TextBlock x:Name="txt" FontSize="{TemplateBinding Property=FontSize}" Foreground="{TemplateBinding Foreground}" Text="{TemplateBinding Property=Content}" VerticalAlignment="Center"/>
            </StackPanel>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter TargetName="bd" Property="Background" Value="#33c4f5"/>
            </Trigger>
            <Trigger Property="IsPressed" Value="true">
                <Setter TargetName="txt" Property="FontSize" Value="11"/>
                <Setter TargetName="img" Property="Width" Value="14"/>
                <Setter TargetName="img" Property="Height" Value="14"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <!-- 图片按钮 -->
    <Style x:Key="stlImgBtn" TargetType="{x:Type Button}">
        <Setter Property="Margin" Value="5,0"/>
        <Setter Property="Height" Value="25"/>
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="Background" Value="#15A6F9"/>
        <Setter Property="Template" Value="{StaticResource tmplImgBtn}"/>
    </Style>
    <!-- 只有图片的按钮 -->
    <ControlTemplate x:Key="tmplBtnImgOnly" TargetType="{x:Type Button}">
        <Border Background="#aa013440"  Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" >
            <Image x:Name="img" Width="16" Height="16" Stretch="Fill" Source="{TemplateBinding Property=Content}"></Image>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsPressed" Value="true">
                <Setter TargetName="img" Property="Margin" Value="2"></Setter>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter TargetName="img" Property="Opacity" Value="0.5"></Setter>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <!-- 输入框样式 -->
    <Style TargetType="{x:Type TextBox}" x:Key="stlTxt">
        <Setter Property="HorizontalAlignment" Value="Left"/>
        <Setter Property="Height" Value="28"/>
        <Setter Property="Margin" Value="5,0,0,0"/>
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="CaretBrush" Value="White"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TextBox}">
                    <Border CornerRadius="2" BorderThickness="0" BorderBrush="#eee" Background="#0A5D7B">
                        <Grid>
                            <Border x:Name="BorderBase" Background="Transparent" BorderThickness="1.4,1.4,1,1"  BorderBrush="Transparent" />
                            <Label x:Name="TextPrompt" Content="{TemplateBinding Tag}" Foreground="Gray" VerticalAlignment="Center"  Visibility="Collapsed" Focusable="False" />
                            <ScrollViewer Margin="2 0 0 0" VerticalAlignment="Center" x:Name="PART_ContentHost"  />
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsFocused" Value="False"/>
                                <Condition Property="Text" Value=""/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Visibility" TargetName="TextPrompt" Value="Visible"/>
                        </MultiTrigger>
                        <Trigger Property="IsFocused" Value="True">
                            <Setter Property="BorderThickness" TargetName="BorderBase" Value="2.4,1.4,1,1"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="Gray" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <!-- 输入框样式 -->
    <Style TargetType="{x:Type RichTextBox}" x:Key="stlRtb">
        <Setter Property="VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="HorizontalAlignment" Value="Left"/>
        <Setter Property="Margin" Value="5 0 0 0"/>
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="CaretBrush" Value="White"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RichTextBox}">
                    <Border BorderThickness="0" BorderBrush="#eee" CornerRadius="2" Background="#0A5D7B">
                        <Grid>
                            <Border x:Name="BorderBase" Background="Transparent" BorderThickness="1.4,1.4,1,1"  BorderBrush="Transparent" />
                            <Label x:Name="TextPrompt" Content="{TemplateBinding Tag}" Foreground="Gray" VerticalAlignment="Top"  Visibility="Collapsed" Focusable="False" />
                            <Border x:Name="border" Margin="0 8 0 5">
                                <ScrollViewer Margin="0" VerticalAlignment="Top" x:Name="PART_ContentHost" Height="{Binding ActualHeight, ElementName=border}" />
                            </Border>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsFocused" Value="False"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Visibility" TargetName="TextPrompt" Value="Visible"/>
                        </MultiTrigger>
                        <Trigger Property="IsFocused" Value="True">
                            <Setter Property="BorderThickness" TargetName="BorderBase" Value="2.4,1.4,1,1"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="Gray" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <!--下拉条目样式-->
    <Style TargetType="{x:Type ComboBoxItem}" x:Key="stlCbxItem">
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Height" Value="28" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ComboBoxItem}">
                    <Grid Background="{TemplateBinding Background}" Margin="0,0.5">
                        <Border x:Name="ItemBackground" CornerRadius="1" IsHitTestVisible="False" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                    BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}"
                                    Background="{TemplateBinding Background}" />
                        <ContentPresenter x:Name="contentPresenter" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter TargetName="ItemBackground" Property="Background" Value="#224466" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="ItemBackground" Property="Background" Value="#226688" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <!-- 下拉框样式 -->
    <Style TargetType="{x:Type ToggleButton}" x:Key="stlToggleButton">
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <Grid Background="Transparent">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="0.7*"/>
                            <ColumnDefinition Width="0.3*" MaxWidth="30" MinWidth="16"/>
                        </Grid.ColumnDefinitions>
                        <TextBlock  Grid.Column="0" Foreground="White" Margin="5 0 0 0" Text="{Binding Text, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}, Mode=FindAncestor}}" VerticalAlignment="Center"/>
                        <Border Grid.Column="1" x:Name="Back" Background="Transparent" BorderThickness="0" BorderBrush="Transparent">
                            <Path x:Name="PathFill" Fill="#1b94e0" Width="8" Height="6" StrokeThickness="0" Data="M5,0 L10,10 L0,10 z" RenderTransformOrigin="0.5,0.5" Stretch="Fill">
                                <Path.RenderTransform>
                                    <TransformGroup>
                                        <ScaleTransform />
                                        <SkewTransform />
                                        <RotateTransform Angle="180"/>
                                        <TranslateTransform/>
                                    </TransformGroup>
                                </Path.RenderTransform>
                            </Path>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="PathFill" Property="Fill" Value="#1b94e0"/>
                            <Setter TargetName="Back" Property="Background" Value="Transparent"/>
                            <Setter TargetName="Back" Property="BorderBrush" Value="Transparent"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <!-- 下拉框样式 -->
    <Style x:Key="stlCbx" TargetType="{x:Type ComboBox}" >
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.CanContentScroll" Value="True"/>
        <Setter Property="HorizontalAlignment" Value="Left"/>
        <Setter Property="Foreground" Value="Black"/>
        <Setter Property="Height" Value="28"/>
        <Setter Property="Margin" Value="0,0,0,0"/>
        <Setter Property="ItemContainerStyle" Value="{StaticResource stlCbxItem}" />
        <Setter Property="ItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <TextBlock Text="{Binding Text}" Foreground="#fff" Margin="0 3 0 3" />
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ComboBox}">
                    <Border BorderThickness="0" BorderBrush="#eee" CornerRadius="2" Background="#0A5D7B">
                        <Grid>
                            <ToggleButton Style="{StaticResource stlToggleButton}" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press"/>
                            <Popup IsOpen="{TemplateBinding IsDropDownOpen}" Placement="Bottom" x:Name="Popup" Focusable="False" AllowsTransparency="True" PopupAnimation="Slide" >
                                <Border MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{TemplateBinding ActualWidth}" x:Name="DropDown" SnapsToDevicePixels="True" Background="Transparent" >
                                    <Border Background="#002244" CornerRadius="2" Margin="0 2 0 0">
                                        <ScrollViewer Margin="4,6,4,6" Style="{DynamicResource ScrollViewerStyle}" MaxHeight="{TemplateBinding MaxDropDownHeight}" SnapsToDevicePixels="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" CanContentScroll="True">
                                            <!-- StackPanel 用于显示子级,方法是将 IsItemsHost 设置为 True -->
                                            <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" Background="#002244" />
                                        </ScrollViewer>
                                    </Border>
                                </Border>
                            </Popup>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <!-- 复选框样式 -->
    <ControlTemplate  x:Key="tmplCkb" TargetType="{x:Type CheckBox}">
        <Grid x:Name="buttonContent" Width="14" Height="14" HorizontalAlignment="Center" VerticalAlignment="Center">
            <Image x:Name="btnImageSrc"  Stretch="Fill" Source="/SunCreate.Common.Controls;Component/Images/Controls/复选1.png"/>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsChecked" Value="true">
                <Setter TargetName="btnImageSrc" Property="Source" Value="/SunCreate.Common.Controls;Component/Images/Controls/复选2.png"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <!-- 单选按钮样式(带背景色) -->
    <ControlTemplate x:Key="tmplRdbBackground"   TargetType="{x:Type RadioButton}">
        <Grid>
            <Border x:Name="bd2" CornerRadius="2" Opacity="1" BorderThickness="1" BorderBrush="{TemplateBinding Background}" SnapsToDevicePixels="True"/>
            <Border x:Name="bd" CornerRadius="2" Opacity="0" Background="{TemplateBinding Background}" SnapsToDevicePixels="True"/>
            <Border x:Name="backgroundRadioBoard" Height="{TemplateBinding Property=Height}" Width="{TemplateBinding Property=Width}" Background="Transparent">
                <TextBlock  FontSize="{TemplateBinding Property=FontSize}" Text="{TemplateBinding Property=Content}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{TemplateBinding Property=Foreground}"/>
            </Border>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsChecked" Value="true">
                <Setter TargetName="bd" Property="Opacity" Value="1"/>
            </Trigger>
            <Trigger Property="IsMouseOver"  Value="true">
                <Setter TargetName="bd" Property="Opacity" Value="1"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <!-- 单选按钮样式(带小圆圈) -->
    <ControlTemplate x:Key="tmplRdbCircle"  TargetType="{x:Type RadioButton}">
        <Border x:Name="radioBtnBoard" CornerRadius="2" Height="{TemplateBinding Property=Height}" Width="{TemplateBinding Property=Width}" Background="Transparent">
            <StackPanel Orientation="Horizontal">
                <Image x:Name="img" Margin="5 0 5 0" Width="14" Height="14" Stretch="Fill" Source="/SunCreate.Common.Controls;Component/Images/Controls/单选1.png"/>
                <TextBlock x:Name="txt" Margin="0 0 5 0" FontSize="{TemplateBinding Property=FontSize}" Text="{TemplateBinding Property=Content}" VerticalAlignment="Center" Foreground="{TemplateBinding Property=Foreground}" />
            </StackPanel>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsChecked" Value="true">
                <Setter TargetName="img" Property="Source" Value="/SunCreate.Common.Controls;Component/Images/Controls/单选2.png"/>
            </Trigger>
            <Trigger Property="IsMouseOver"  Value="true">
                <Setter TargetName="radioBtnBoard" Property="Background" Value="#331aa4f5"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <!-- 单选按钮样式 -->
    <ControlTemplate x:Key="tmplRdb"  TargetType="{x:Type RadioButton}">
        <Border x:Name="radioBtnBoard" CornerRadius="2" Height="{TemplateBinding Property=Height}" Width="{TemplateBinding Property=Width}" Background="Transparent">
            <TextBlock x:Name="txt" FontSize="{TemplateBinding Property=FontSize}" Text="{TemplateBinding Property=Content}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{TemplateBinding Property=Foreground}"/>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsChecked" Value="true">
                <Setter TargetName="radioBtnBoard" Property="Background" Value="#1aa4f5"/>
            </Trigger>
            <Trigger Property="IsMouseOver"  Value="true">
                <Setter TargetName="radioBtnBoard" Property="Background" Value="#331aa4f5"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <!-- 单选按钮样式 -->
    <Style x:Key="stlRdb" TargetType="{x:Type RadioButton}">
        <Setter Property="FontSize" Value="11"/>
        <Setter Property="Height" Value="22"/>
        <Setter Property="Width" Value="50"/>
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="Margin" Value="5,0"/>
        <Setter Property="Template" Value="{StaticResource tmplRdb}"/>
    </Style>
    <!-- 单选按钮样式(带小圆圈) -->
    <Style x:Key="stlRdbCircle" TargetType="{x:Type RadioButton}">
        <Setter Property="FontSize" Value="11"/>
        <Setter Property="Height" Value="22"/>
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="Margin" Value="5,0"/>
        <Setter Property="Template" Value="{StaticResource tmplRdbCircle}"/>
    </Style>
    <!-- 单选按钮样式(带背景色) -->
    <Style x:Key="stlRdbBackground" TargetType="{x:Type RadioButton}">
        <Setter Property="FontSize" Value="11"/>
        <Setter Property="Height" Value="22"/>
        <Setter Property="Width" Value="50"/>
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="Margin" Value="5,0"/>
        <Setter Property="Template" Value="{StaticResource tmplRdbBackground}"/>
    </Style>
    <!--Slider样式-->
    <Style x:Key="stlRepeatButtonLeft" TargetType="RepeatButton">
        <Setter Property="Focusable" Value="false" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="RepeatButton">
                    <Border Background="#01ffff" SnapsToDevicePixels="True" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="stlRepeatButtonRight" TargetType="RepeatButton">
        <Setter Property="Focusable" Value="false" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="RepeatButton">
                    <Border Background="#0998B8" SnapsToDevicePixels="True" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="stlThumb" TargetType="Thumb">
        <Setter Property="Focusable" Value="false" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Thumb">
                    <Grid>
                        <Border Margin="0 -4 0 -4"  Background="#01ffff" Width="8" Height="12" SnapsToDevicePixels="True">
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="stlThumbReadOnly" TargetType="Thumb">
        <Setter Property="Focusable" Value="false" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Thumb">
                    <Grid>
                        <Border Margin="0 0 0 0" Background="#01ffff" Width="0" Height="4">
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="stlSlider" TargetType="Slider">
        <Setter Property="Focusable" Value="false" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Slider">
                    <Grid>
                        <Border Height="4">
                            <Track Name="PART_Track">
                                <Track.DecreaseRepeatButton>
                                    <RepeatButton Style="{StaticResource stlRepeatButtonLeft}"
                                Command="Slider.DecreaseLarge"/>
                                </Track.DecreaseRepeatButton>
                                <Track.IncreaseRepeatButton>
                                    <RepeatButton Style="{StaticResource stlRepeatButtonRight}"
                                Command="Slider.IncreaseLarge"/>
                                </Track.IncreaseRepeatButton>
                                <Track.Thumb>
                                    <Thumb Style="{StaticResource stlThumb}"/>
                                </Track.Thumb>
                            </Track>
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="stlSliderReadOnly" TargetType="Slider">
        <Setter Property="IsEnabled" Value="false" />
        <Setter Property="Focusable" Value="false" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Slider">
                    <Grid>
                        <Border Height="4">
                            <Track Name="PART_Track">
                                <Track.DecreaseRepeatButton>
                                    <RepeatButton Style="{StaticResource stlRepeatButtonLeft}"
                                Command="Slider.DecreaseLarge"/>
                                </Track.DecreaseRepeatButton>
                                <Track.IncreaseRepeatButton>
                                    <RepeatButton Style="{StaticResource stlRepeatButtonRight}"
                                Command="Slider.IncreaseLarge"/>
                                </Track.IncreaseRepeatButton>
                                <Track.Thumb>
                                    <Thumb Style="{StaticResource stlThumbReadOnly}"/>
                                </Track.Thumb>
                            </Track>
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <!--ToolTip样式-->
    <Style x:Key="stlToolTip" TargetType="ToolTip">
        <Setter Property ="Background" Value="#99001133"></Setter>
        <Setter Property ="BorderThickness" Value="0"></Setter>
        <Setter Property ="ContentTemplate">
            <Setter.Value>
                <DataTemplate>
                    <TextBlock Text="{TemplateBinding Content}" Foreground="#fff" Background="Transparent" TextWrapping="Wrap"></TextBlock>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
View Code

 单选按钮样式(模拟tab页):

技术图片
<!-- 单选按钮样式 -->
<ControlTemplate x:Key="tmplRadioButton" TargetType="{x:Type RadioButton}">
    <Grid>
        <Border x:Name="bd" Background="Transparent" BorderThickness="0 0 0 3" BorderBrush="Transparent" SnapsToDevicePixels="True">
            <TextBlock x:Name="txt" Margin="5 0 5 0" Text="{TemplateBinding Content}" Foreground="#babec2" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>
        </Border>
    </Grid>
    <ControlTemplate.Triggers>
        <Trigger Property="IsChecked" Value="true">
            <Setter TargetName="bd" Property="BorderBrush" Value="#01f9fe"/>
            <Setter TargetName="txt" Property="Foreground" Value="#38faf4"/>
        </Trigger>
        <Trigger Property="IsMouseOver"  Value="true">
            <Setter TargetName="txt" Property="Foreground" Value="#38faf4"/>
        </Trigger>
    </ControlTemplate.Triggers>
</ControlTemplate>
View Code

 单选按钮样式(模拟tab页)效果图:

技术图片

 列表样式(ListView样式、DataGrid样式):

技术图片
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <!--ListView样式(1):无边框,奇偶行颜色不相同-->
    <Style x:Key="ItemContainerStyle1" TargetType="{x:Type ListViewItem}" >
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Foreground" Value="White"></Setter>
        <Setter Property="FontSize" Value="12" />
        <Setter Property="Height" Value="40"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListViewItem">
                    <Border x:Name="tBorder"  Background="{TemplateBinding Background}">
                        <GridViewRowPresenter Content="{TemplateBinding Content}" Columns="{TemplateBinding GridView.ColumnCollection}"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="ListView.AlternationIndex" Value="0">
                            <Setter Property="Background" Value="{StaticResource ItemsAlternationIndexBackground0}"/>
                        </Trigger>
                        <Trigger Property="ListView.AlternationIndex" Value="1">
                            <Setter Property="Background" Value="{StaticResource ItemsAlternationIndexBackground1}"/>
                        </Trigger>
                        <Trigger Property="IsSelected" Value="true">
                            <Setter Property="Foreground" Value="{StaticResource ItemSelectedForeground}"/>
                            <Setter TargetName="tBorder" Property="Background" Value="{StaticResource ItemSelectedBackground}" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="Foreground" Value="{StaticResource ItemMouseOverForeground}"/>
                            <Setter TargetName="tBorder" Property="Background" Value="{StaticResource ItemMouseOverBackground}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--无边框 带下划线-->
    <Style x:Key="BottomLineRowStyle" TargetType="{x:Type ListViewItem}" >
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListViewItem">
                    <Border BorderThickness="0,0,0,1" BorderBrush="{StaticResource borderContent}">
                        <GridViewRowPresenter Content="{TemplateBinding Content}" Columns="{TemplateBinding GridView.ColumnCollection}"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Foreground" Value="White"></Setter>
        <Setter Property="FontSize" Value="12" />
        <Setter Property="Height" Value="40"/>
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="true">
                <Setter Property="Foreground" Value="#ff5e5e"/>
            </Trigger>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Foreground" Value="#ff5e5e"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="ColumnHeaderContainerStyle1" TargetType="{x:Type GridViewColumnHeader}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Foreground" Value="{StaticResource HeaderForeground}"></Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
                    <Grid Background="Transparent" >
                        <Border Padding="{TemplateBinding Padding}">
                            <ContentPresenter HorizontalAlignment="Center" Margin="5,4,1,3"  VerticalAlignment="Center"  />
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ListViewStyle1" TargetType="ListView">
        <Setter Property="ItemContainerStyle" Value="{StaticResource ItemContainerStyle1}"></Setter>
        <Setter Property="AlternationCount" Value="2"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListView">
                    <Border Background="Transparent">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="40"/>
                                <RowDefinition Height="1*"/>
                            </Grid.RowDefinitions>
                            <Border CornerRadius="3" BorderThickness="{StaticResource borderThickness}" BorderBrush="{StaticResource HeaderBorderBrush}" Background="{StaticResource HeaderBackground}">
                                <GridViewHeaderRowPresenter  
                                                Columns="{Binding Path=TemplatedParent.View.Columns, RelativeSource={RelativeSource Self}}"
                                                ColumnHeaderContainerStyle="{StaticResource ColumnHeaderContainerStyle1}"
                                                AllowsColumnReorder="{Binding  Path=TemplatedParent.View.AllowsColumnReorder,  RelativeSource={RelativeSource Self}}"
                                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" >
                                </GridViewHeaderRowPresenter>
                            </Border>
                            <ScrollViewer Margin="0" Grid.Row="1">
                                <ItemsPresenter />
                            </ScrollViewer>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--ListView样式(2):带边框,奇偶行颜色不相同-->
    <Style x:Key="ItemContainerStyle2" TargetType="{x:Type ListViewItem}" >
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListViewItem">
                    <Border Background="{TemplateBinding Background}" BorderThickness="0 0 1 1" BorderBrush="{StaticResource borderContent}">
                        <GridViewRowPresenter Content="{TemplateBinding Content}" Columns="{TemplateBinding GridView.ColumnCollection}" Margin="-6 -3"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Foreground" Value="White"></Setter>
        <Setter Property="FontSize" Value="12" />
        <Setter Property="Height" Value="40"/>
        <Style.Triggers>
            <Trigger Property="ListView.AlternationIndex" Value="0">
                <Setter Property="Background" Value="#023746"/>
            </Trigger>
            <Trigger Property="IsSelected" Value="true">
                <Setter Property="Foreground" Value="#FF5E5E"/>
            </Trigger>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Foreground" Value="#FF5E5E"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="ColumnHeaderContainerStyle2" TargetType="{x:Type GridViewColumnHeader}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Foreground" Value="#21DDFB"></Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
                    <Grid Name="g" Background="Transparent" >
                        <Border Name="bd"  Padding="{TemplateBinding Padding}" BorderThickness="0 0 1 0" BorderBrush="{StaticResource borderContent}">
                            <ContentPresenter HorizontalAlignment="Center"  VerticalAlignment="Center"  Margin="-5 -3"/>
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ListViewStyle2" TargetType="ListView">
        <Setter Property="ItemContainerStyle" Value="{StaticResource ItemContainerStyle2}"></Setter>
        <Setter Property="AlternationCount" Value="2"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListView">
                    <Border Background="Transparent">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="40"/>
                                <RowDefinition Height="1*"/>
                            </Grid.RowDefinitions>
                            <Border Background="#034558" BorderThickness="{StaticResource borderThickness}" BorderBrush="#087E85">
                                <GridViewHeaderRowPresenter  
                                                Columns="{Binding Path=TemplatedParent.View.Columns, RelativeSource={RelativeSource Self}}"
                                                ColumnHeaderContainerStyle="{StaticResource ColumnHeaderContainerStyle2}"
                                                AllowsColumnReorder="{Binding  Path=TemplatedParent.View.AllowsColumnReorder,  RelativeSource={RelativeSource Self}}"
                                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" >
                                </GridViewHeaderRowPresenter>
                            </Border>
                            <ScrollViewer Margin="0" Grid.Row="1">
                                <ItemsPresenter />
                            </ScrollViewer>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--ListView样式(3):无边框,奇偶行颜色不相同,菜单上使用-->
    <Style x:Key="ItemContainerStyle3" TargetType="{x:Type ListViewItem}" >
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListViewItem">
                    <Border Background="{TemplateBinding Background}">
                        <GridViewRowPresenter Content="{TemplateBinding Content}" Columns="{TemplateBinding GridView.ColumnCollection}"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Foreground" Value="#1a1a1a"></Setter>
        <Setter Property="FontSize" Value="12" />
        <Setter Property="Margin" Value="0" />
        <Setter Property="Height" Value="30"/>
        <Style.Triggers>
            <Trigger Property="ListView.AlternationIndex" Value="0">
                <Setter Property="Background" Value="#e8e0e8e8"/>
            </Trigger>
            <Trigger Property="IsSelected" Value="true">
                <Setter Property="Foreground" Value="#FF5E5E"/>
            </Trigger>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Foreground" Value="#FF5E5E"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="ColumnHeaderContainerStyle3" TargetType="{x:Type GridViewColumnHeader}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Foreground" Value="#1a1a1a"></Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
                    <Grid Name="g" >
                        <Border Name="bd" Padding="{TemplateBinding Padding}" Margin="5 0 5 0">
                            <ContentPresenter VerticalAlignment="Center" />
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ListViewStyle3" TargetType="ListView">
        <Setter Property="ItemContainerStyle" Value="{StaticResource ItemContainerStyle3}"></Setter>
        <Setter Property="AlternationCount" Value="2"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListView">
                    <Border>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="40"/>
                                <RowDefinition Height="1*"/>
                            </Grid.RowDefinitions>
                            <Border BorderThickness="0" CornerRadius="2" Margin="5 5 5 5" Background="#ffffff">
                                <GridViewHeaderRowPresenter  
                                          Columns="{Binding Path=TemplatedParent.View.Columns, RelativeSource={RelativeSource Self}}"
                                          ColumnHeaderContainerStyle="{StaticResource ColumnHeaderContainerStyle3}"
                                          AllowsColumnReorder="{Binding  Path=TemplatedParent.View.AllowsColumnReorder,  RelativeSource={RelativeSource Self}}"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" >
                                </GridViewHeaderRowPresenter>
                            </Border>
                            <ScrollViewer Grid.Row="1" Margin="5 0 5 0" HorizontalScrollBarVisibility="Hidden">
                                <ItemsPresenter />
                            </ScrollViewer>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--ListView样式(4):无边框,奇偶行颜色不相同,弹出窗口使用-->
    <Style x:Key="ItemContainerStyle4" TargetType="{x:Type ListViewItem}" >
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListViewItem">
                    <Border Background="{TemplateBinding Background}">
                        <GridViewRowPresenter Content="{TemplateBinding Content}" Columns="{TemplateBinding GridView.ColumnCollection}"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Foreground" Value="Black"></Setter>
        <Setter Property="FontSize" Value="12" />
        <Setter Property="Height" Value="30"/>
        <Style.Triggers>
            <Trigger Property="ListView.AlternationIndex" Value="0">
                <Setter Property="Background" Value="#EEEEEE"/>
            </Trigger>
            <Trigger Property="IsSelected" Value="true">
                <Setter Property="Foreground" Value="#FF5E5E"/>
            </Trigger>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Foreground" Value="#FF5E5E"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="ColumnHeaderContainerStyle4" TargetType="{x:Type GridViewColumnHeader}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Foreground" Value="Black"></Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
                    <Grid Name="g" Background="Transparent" >
                        <Border Name="bd"  Padding="{TemplateBinding Padding}">
                            <ContentPresenter HorizontalAlignment="Center" Margin="5,4,1,3"  VerticalAlignment="Center"  />
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ListViewStyle4" TargetType="ListView">
        <Setter Property="ItemContainerStyle" Value="{StaticResource ItemContainerStyle4}"></Setter>
        <Setter Property="AlternationCount" Value="2"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListView">
                    <Border Background="Transparent">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="30"/>
                                <RowDefinition Height="1*"/>
                            </Grid.RowDefinitions>
                            <Border Background="#D6E5F1" BorderThickness="{StaticResource borderThickness}" BorderBrush="#087E85" CornerRadius="3">
                                <GridViewHeaderRowPresenter  
                                                Columns="{Binding Path=TemplatedParent.View.Columns, RelativeSource={RelativeSource Self}}"
                                                ColumnHeaderContainerStyle="{StaticResource ColumnHeaderContainerStyle4}"
                                                AllowsColumnReorder="{Binding  Path=TemplatedParent.View.AllowsColumnReorder,  RelativeSource={RelativeSource Self}}"
                                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" >
                                </GridViewHeaderRowPresenter>
                            </Border>
                            <ScrollViewer Margin="0" Grid.Row="1">
                                <ItemsPresenter />
                            </ScrollViewer>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--DataGrid样式:带边框,奇偶行颜色不相同-->
    <Style x:Key="DefaultColumnHeaderGripperStyle" TargetType="{x:Type Thumb}">
        <Setter Property="Width" Value="8" />
        <Setter Property="Background" Value="{StaticResource HeaderBorderBrush}" />
        <Setter Property="Cursor" Value="SizeWE" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Padding="{TemplateBinding Padding}" Background="Transparent" Margin="0 0 0 2">
                        <Rectangle HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Width="1" Fill="{TemplateBinding Background}" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="DefaultDataGridColumnHeader" TargetType="{x:Type DataGridColumnHeader}">
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="MinWidth" Value="5" />
        <Setter Property="MinHeight" Value="40" />
        <Setter Property="Height" Value="40" />
        <Setter Property="Foreground" Value="{StaticResource HeaderForeground}" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Padding" Value="10,4,4,7" />
        <Setter Property="Margin" Value="0,0,0,0" />
        <Setter Property="FontWeight" Value="SemiBold"></Setter>
        <Setter Property="FontSize" Value="12" />
        <Setter Property="BorderThickness" Value="0,0,0,3" />
        <Setter Property="BorderBrush" Value="{StaticResource borderContent}" />
        <Setter Property="Background" Value="{StaticResource HeaderBackground}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="auto" />
                        </Grid.ColumnDefinitions>
                        <Border x:Name="BackgroundBorder" BorderThickness="{TemplateBinding BorderThickness}"
                                Grid.ColumnSpan="2" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" />
                        <ContentPresenter x:Name="HeaderContent"
                                          Content="{TemplateBinding Content}"
                                          ContentTemplate="{TemplateBinding ContentTemplate}"
                                          Margin="{TemplateBinding Padding}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          RecognizesAccessKey="True"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        <TextBlock x:Name="SortArrow"  Grid.Column="1" Width="20"
                                       Visibility="Collapsed" FontSize="16" Margin="1,1,3,1" />

                        <Thumb x:Name="PART_LeftHeaderGripper" HorizontalAlignment="Left" HorizontalContentAlignment="Left"
                               Style="{StaticResource DefaultColumnHeaderGripperStyle}" />

                        <Thumb x:Name="PART_RightHeaderGripper" HorizontalAlignment="Right" HorizontalContentAlignment="Right" Background="Transparent"
                               Style="{StaticResource DefaultColumnHeaderGripperStyle}" Grid.Column="1" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <!--显示排序标示-->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True" />
                                <Condition Property="SortDirection" Value="{x:Null}" />
                                <Condition Property="CanUserSort" Value="true" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
                        </MultiTrigger>
                        <!--可排序列鼠标样式-->
                        <Trigger Property="CanUserSort" Value="True">
                            <Setter Property="Cursor" Value="Hand"></Setter>
                        </Trigger>
                        <!--升序-->
                        <Trigger Property="SortDirection" Value="Ascending">
                            <Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
                        </Trigger>
                        <!--降序-->
                        <Trigger Property="SortDirection" Value="Descending">
                            <Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
                            <Setter TargetName="SortArrow" Property="Text" Value="&#xe625;"/>
                        </Trigger>
                        <!--第一列左边不显示分割线-->
                        <Trigger Property="DisplayIndex" Value="2">
                            <Setter Property="Visibility" Value="Collapsed" TargetName="PART_LeftHeaderGripper" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="DefaultDataGridRow" TargetType="{x:Type DataGridRow}">
        <Setter Property="Foreground" Value="{StaticResource TextForeground}" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Margin" Value="0,0,0,0" />

        <Style.Triggers>
            <Trigger Property="AlternationIndex" Value="0" >
                <Setter Property="Background" Value="{StaticResource ItemsAlternationIndexBackground0}" />
            </Trigger>
            <Trigger Property="AlternationIndex" Value="1" >
                <Setter Property="Background" Value="{StaticResource ItemsAlternationIndexBackground1}" />
            </Trigger>
            <Trigger Property="IsSelected" Value="True">
                <Setter  Property="Background" Value="{StaticResource ItemSelectedBackground}" />
                <Setter Property="Foreground" Value="{StaticResource ItemSelectedForeground}" />
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsSelected" Value="True" />
                    <Condition Property="Selector.IsSelectionActive" Value="True" />
                </MultiTrigger.Conditions>
                <Setter  Property="Background" Value="{StaticResource ItemSelectedBackground}" />
                <Setter Property="Foreground" Value="{StaticResource ItemSelectedForeground}" />
            </MultiTrigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=IsMouseOver, RelativeSource={RelativeSource Self}}" Value="True" />
                </MultiDataTrigger.Conditions>
                <Setter  Property="Background" Value="{StaticResource ItemMouseOverBackground}" />
                <Setter Property="Foreground" Value="{StaticResource ItemMouseOverForeground}" />
            </MultiDataTrigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="DefaultRowHeaderGripperStyle" TargetType="{x:Type Thumb}">
        <Setter Property="Height" Value="6" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Cursor" Value="SizeNS" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Padding="{TemplateBinding Padding}" Background="Transparent"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="DefaultDataGridRowHeader" TargetType="{x:Type DataGridRowHeader}">
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="BorderThickness" Value="0,0,1,0" />
        <Setter Property="Margin" Value="0,0,0,0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridRowHeader}">
                    <Grid>
                        <Border BorderBrush="{TemplateBinding BorderBrush}"
                                Background="{TemplateBinding Background}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Padding="{TemplateBinding Padding}"
                                Margin="{TemplateBinding Margin}"
                                SnapsToDevicePixels="True">
                            <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
                        </Border>
                        <Thumb x:Name="PART_TopHeaderGripper" VerticalContentAlignment="Top"
                               VerticalAlignment="Top" Background="Transparent" Style="{StaticResource DefaultRowHeaderGripperStyle}" />
                        <Thumb x:Name="PART_BottomHeaderGripper" VerticalContentAlignment="Bottom"
                               VerticalAlignment="Bottom" Style="{StaticResource DefaultRowHeaderGripperStyle}" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="DefaultDataGridCell"
           TargetType="{x:Type DataGridCell}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridCell}">
                    <Border BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Background="{TemplateBinding Background}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}"
                                          Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                          Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">

                        </ContentPresenter>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Foreground" Value="{StaticResource ItemSelectedForeground}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="DefaultDataGrid" TargetType="{x:Type DataGrid}">
        <Setter Property="MinRowHeight" Value="25" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="{StaticResource GridLinesBrush}" />
        <Setter Property="BorderThickness" Value="{StaticResource borderThickness}" />
        <Setter Property="HorizontalGridLinesBrush" Value="{StaticResource GridLinesBrush}" />
        <Setter Property="VerticalGridLinesBrush" Value="{StaticResource GridLinesBrush}" />
        <Setter Property="ColumnHeaderStyle" Value="{StaticResource DefaultDataGridColumnHeader}" />
        <Setter Property="RowHeaderStyle" Value="{StaticResource DefaultDataGridRowHeader}" />
        <Setter Property="CellStyle" Value="{StaticResource DefaultDataGridCell}" />
        <Setter Property="RowStyle" Value="{StaticResource DefaultDataGridRow}" />
        <Setter Property="HeadersVisibility" Value="All" />
        <Setter Property="EnableRowVirtualization" Value="True" />
        <Setter Property="EnableColumnVirtualization" Value="False" />
        <Setter Property="AutoGenerateColumns" Value="False" />
        <Setter Property="IsReadOnly" Value="True" />
        <Setter Property="SelectionMode" Value="Single" />
        <Setter Property="SelectionUnit" Value="FullRow" />
        <Setter Property="GridLinesVisibility" Value="All" />
        <Setter Property="AlternationCount" Value="2"></Setter>
        <Setter Property="ScrollViewer.CanContentScroll" Value="True" />
        <Setter Property="VirtualizingStackPanel.IsVirtualizing" Value="True"></Setter>
        <Setter Property="VirtualizingStackPanel.VirtualizationMode" Value="Recycling" />
        <Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" />
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />
        <!--列头移动列时候分割线样式-->
        <Setter Property="DropLocationIndicatorStyle">
            <Setter.Value>
                <Style TargetType="Separator">
                    <Setter Property="Background" Value="{StaticResource HeaderBorderBrush}" />
                    <Setter Property="Width" Value="2.5" />
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="Separator">
                                <Rectangle Fill="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}" />
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </Setter.Value>
        </Setter>
        <!--DataGrid控件模板-->
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGrid}">
                    <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" x:Name="border"
                            Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="40"/>
                                <RowDefinition Height="1*"/>
                            </Grid.RowDefinitions>
                            <Border Background="#D6E5F1" BorderThickness="{StaticResource borderThickness}" BorderBrush="{StaticResource GridLinesBrush}">
                                <!--表格头部-->
                                <DataGridColumnHeadersPresenter x:Name="PART_ColumnHeadersPresenter" Grid.Column="1" Grid.ColumnSpan="2" Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Column}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
                            </Border>
                            <ScrollViewer Margin="0" Grid.Row="1">
                                <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                            </ScrollViewer>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Opacity" Value="0.6" TargetName="border" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsGrouping" Value="true">
                <Setter Property="ScrollViewer.CanContentScroll" Value="false" />
            </Trigger>
        </Style.Triggers>
    </Style>

</ResourceDictionary>
View Code

 ScrollViewer样式:

技术图片
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Style x:Key="ScrollBarThumb"
           TargetType="{x:Type Thumb}">
        <Setter Property="OverridesDefaultStyle"
                Value="true"/>
        <Setter Property="IsTabStop"
                Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Grid>
                        <Rectangle
                            Fill="#90000000"
                            RadiusX="3"
                            RadiusY="3"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="HorizontalScrollBarPageButton"
           TargetType="{x:Type RepeatButton}">
        <Setter Property="OverridesDefaultStyle"
                Value="true"/>
        <Setter Property="Background"
                Value="Transparent"/>
        <Setter Property="Focusable"
                Value="false"/>
        <Setter Property="IsTabStop"
                Value="false"/>
        <Setter Property="Opacity"
                Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Rectangle Fill="{TemplateBinding Background}"
                               Width="{TemplateBinding Width}"
                               Height="{TemplateBinding Height}"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="VerticalScrollBarPageButton"
           TargetType="{x:Type RepeatButton}">
        <Setter Property="OverridesDefaultStyle"
                Value="true"/>
        <Setter Property="Background"
                Value="Transparent"/>
        <Setter Property="Focusable"
                Value="false"/>
        <Setter Property="IsTabStop"
                Value="false"/>
        <Setter Property="Opacity"
                Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Rectangle Fill="{TemplateBinding Background}"
                               Width="{TemplateBinding Width}"
                               Height="{TemplateBinding Height}"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="for_scrollbar"
           TargetType="{x:Type ScrollBar}">
        <Setter Property="Stylus.IsPressAndHoldEnabled"
                Value="false"/>
        <Setter Property="Stylus.IsFlicksEnabled"
                Value="false"/>
        <Setter Property="Background"
                Value="Transparent"/>
        <Setter Property="Margin"
                Value="0,1,1,6"/>
        <Setter Property="Width"
                Value="7"/>
        <Setter Property="MinWidth"
                Value="7"/>
        <Setter Property="Opacity"
                Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollBar}">
                    <Grid x:Name="Bg" SnapsToDevicePixels="true">
                        <Track x:Name="PART_Track"
                               IsEnabled="{TemplateBinding IsMouseOver}"
                               IsDirectionReversed="true">
                            <Track.DecreaseRepeatButton>
                                <RepeatButton
                                    Style="{StaticResource VerticalScrollBarPageButton}"
                                    Command="{x:Static ScrollBar.PageUpCommand}"/>
                            </Track.DecreaseRepeatButton>
                            <Track.IncreaseRepeatButton>
                                <RepeatButton
                                    Style="{StaticResource VerticalScrollBarPageButton}"
                                    Command="{x:Static ScrollBar.PageDownCommand}"/>
                            </Track.IncreaseRepeatButton>
                            <Track.Thumb>
                                <Thumb Style="{StaticResource ScrollBarThumb}"/>
                            </Track.Thumb>
                        </Track>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="Orientation"
                     Value="Horizontal">
                <Setter Property="Background"
                        Value="Transparent"/>
                <Setter Property="Margin"
                        Value="1,0,6,1"/>
                <Setter Property="Height"
                        Value="5"/>
                <Setter Property="MinHeight"
                        Value="5"/>
                <Setter Property="Width"
                        Value="Auto"/>
                <Setter Property="Opacity"
                        Value="0"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ScrollBar}">
                            <Grid x:Name="Bg" SnapsToDevicePixels="true">
                                <Track x:Name="PART_Track"
                                       IsEnabled="{TemplateBinding IsMouseOver}">
                                    <Track.DecreaseRepeatButton>
                                        <RepeatButton Style="{StaticResource HorizontalScrollBarPageButton}"
                                                      Command="{x:Static ScrollBar.PageLeftCommand}"/>
                                    </Track.DecreaseRepeatButton>
                                    <Track.IncreaseRepeatButton>
                                        <RepeatButton Style="{StaticResource HorizontalScrollBarPageButton}"
                                                      Command="{x:Static ScrollBar.PageRightCommand}"/>
                                    </Track.IncreaseRepeatButton>
                                    <Track.Thumb>
                                        <Thumb Style="{StaticResource ScrollBarThumb}"/>
                                    </Track.Thumb>
                                </Track>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>
    </Style>

    <!-- ScrollViewer -->
    <Style TargetType="{x:Type ScrollViewer}">
        <Setter Property="BorderBrush"
                Value="LightGray"/>
        <Setter Property="BorderThickness"
                Value="0"/>
        <Setter Property="HorizontalContentAlignment"
                Value="Left"/>
        <Setter Property="VerticalContentAlignment"
                Value="Top"/>
        <Setter Property="VerticalScrollBarVisibility"
                Value="Auto"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                    <Border  BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            SnapsToDevicePixels="True">
                        <Grid Background="{TemplateBinding Background}">
                            <ScrollContentPresenter
                                Cursor="{TemplateBinding Cursor}"
                                Margin="{TemplateBinding Padding}"
                                ContentTemplate="{TemplateBinding ContentTemplate}"
                                CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}" />
                            <ScrollBar x:Name="PART_VerticalScrollBar"
                                       HorizontalAlignment="Right"
                                       Maximum="{TemplateBinding ScrollableHeight}"
                                       Orientation="Vertical"
                                       Style="{StaticResource for_scrollbar}"
                                       ViewportSize="{TemplateBinding ViewportHeight}"
                                       Value="{TemplateBinding VerticalOffset}"
                                       Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"/>
                            <ScrollBar x:Name="PART_HorizontalScrollBar"
                                       Maximum="{TemplateBinding ScrollableWidth}"
                                       Orientation="Horizontal"
                                       Style="{StaticResource for_scrollbar}"
                                       VerticalAlignment="Bottom"
                                       Value="{TemplateBinding HorizontalOffset}"
                                       ViewportSize="{TemplateBinding ViewportWidth}"
                                       Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <EventTrigger RoutedEvent="ScrollChanged">
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation
                                        Storyboard.TargetName="PART_VerticalScrollBar"
                                        Storyboard.TargetProperty="Opacity"
                                        To="1"
                                        Duration="0:0:1"/>
                                    <DoubleAnimation
                                        Storyboard.TargetName="PART_VerticalScrollBar"
                                        Storyboard.TargetProperty="Opacity"
                                        To="0"
                                        Duration="0:0:1"
                                        BeginTime="0:0:1"/>
                                    <DoubleAnimation
                                        Storyboard.TargetName="PART_HorizontalScrollBar"
                                        Storyboard.TargetProperty="Opacity"
                                        To="1"
                                        Duration="0:0:1"/>
                                    <DoubleAnimation
                                        Storyboard.TargetName="PART_HorizontalScrollBar"
                                        Storyboard.TargetProperty="Opacity"
                                        To="0"
                                        Duration="0:0:1"
                                        BeginTime="0:0:1"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                        <EventTrigger RoutedEvent="MouseEnter"
                                      SourceName="PART_VerticalScrollBar">
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation
                                        Storyboard.TargetName="PART_VerticalScrollBar"
                                        Storyboard.TargetProperty="Opacity"
                                        To="1"
                                        Duration="0:0:1"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                        <EventTrigger RoutedEvent="MouseLeave"
                                      SourceName="PART_VerticalScrollBar">
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation
                                        Storyboard.TargetName="PART_VerticalScrollBar"
                                        Storyboard.TargetProperty="Opacity"
                                        To="0"
                                        Duration="0:0:1"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                        <EventTrigger RoutedEvent="MouseEnter"
                                      SourceName="PART_HorizontalScrollBar">
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation
                                        Storyboard.TargetName="PART_HorizontalScrollBar"
                                        Storyboard.TargetProperty="Opacity"
                                        To="1"
                                        Duration="0:0:1"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                        <EventTrigger RoutedEvent="MouseLeave"
                                      SourceName="PART_HorizontalScrollBar">
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation
                                        Storyboard.TargetName="PART_HorizontalScrollBar"
                                        Storyboard.TargetProperty="Opacity"
                                        To="0"
                                        Duration="0:0:1"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="{x:Static GridView.GridViewScrollViewerStyleKey}"
           TargetType="{x:Type ScrollViewer}">
        <Setter Property="BorderBrush"
                Value="LightGray"/>
        <Setter Property="BorderThickness"
                Value="0"/>
        <Setter Property="HorizontalContentAlignment"
                Value="Left"/>
        <Setter Property="HorizontalScrollBarVisibility"
                Value="Auto"/>
        <Setter Property="VerticalContentAlignment"
                Value="Top"/>
        <Setter Property="VerticalScrollBarVisibility"
                Value="Auto"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                    <Border  BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            SnapsToDevicePixels="True">
                        <Grid Background="{TemplateBinding Background}">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="auto"/>
                                <RowDefinition Height="1*"/>
                            </Grid.RowDefinitions>
                                <GridViewHeaderRowPresenter Margin="2,0,2,0"
                                          Columns="{Binding Path=TemplatedParent.View.Columns,
                
                                    RelativeSource={RelativeSource TemplatedParent}}"
                                          ColumnHeaderContainerStyle="{Binding  Path=TemplatedParent.View.ColumnHeaderContainerStyle,RelativeSource={RelativeSource TemplatedParent}}"
                                          ColumnHeaderTemplate="{Binding Path=TemplatedParent.View.ColumnHeaderTemplate, RelativeSource={RelativeSource TemplatedParent}}"
                                          ColumnHeaderTemplateSelector="{Binding Path=TemplatedParent.View.ColumnHeaderTemplateSelector, RelativeSource={RelativeSource TemplatedParent}}"
                                          AllowsColumnReorder="{Binding  Path=TemplatedParent.View.AllowsColumnReorder,  RelativeSource={RelativeSource TemplatedParent}}"
                                          ColumnHeaderContextMenu="{Binding Path=TemplatedParent.View.ColumnHeaderContextMenu, RelativeSource={RelativeSource TemplatedParent}}"
                                          ColumnHeaderToolTip="{Binding  Path=TemplatedParent.View.ColumnHeaderToolTip,  RelativeSource={RelativeSource TemplatedParent}}"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                            <ScrollContentPresenter Grid.Row="1"
                                Cursor="{TemplateBinding Cursor}"
                                Margin="{TemplateBinding Padding}"
                                ContentTemplate="{TemplateBinding ContentTemplate}"/>
                            <ScrollBar x:Name="PART_VerticalScrollBar" Grid.Row="1"
                                       HorizontalAlignment="Right"
                                       Maximum="{TemplateBinding ScrollableHeight}"
                                       Orientation="Vertical"
                                       Style="{StaticResource for_scrollbar}"
                                       ViewportSize="{TemplateBinding ViewportHeight}"
                                       Value="{TemplateBinding VerticalOffset}"
                                       Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"/>
                            <ScrollBar x:Name="PART_HorizontalScrollBar" Grid.Row="1"
                                       Maximum="{TemplateBinding ScrollableWidth}"
                                       Orientation="Horizontal"
                                       Style="{StaticResource for_scrollbar}"
                                       VerticalAlignment="Bottom"
                                       Value="{TemplateBinding HorizontalOffset}"
                                       ViewportSize="{TemplateBinding ViewportWidth}"
                                       Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <EventTrigger RoutedEvent="ScrollChanged">
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation
                                        Storyboard.TargetName="PART_VerticalScrollBar"
                                        Storyboard.TargetProperty="Opacity"
                                        To="1"
                                        Duration="0:0:1"/>
                                    <DoubleAnimation
                                        Storyboard.TargetName="PART_VerticalScrollBar"
                                        Storyboard.TargetProperty="Opacity"
                                        To="0"
                                        Duration="0:0:1"
                                        BeginTime="0:0:1"/>
                                    <DoubleAnimation
                                        Storyboard.TargetName="PART_HorizontalScrollBar"
                                        Storyboard.TargetProperty="Opacity"
                                        To="1"
                                        Duration="0:0:1"/>
                                    <DoubleAnimation
                                        Storyboard.TargetName="PART_HorizontalScrollBar"
                                        Storyboard.TargetProperty="Opacity"
                                        To="0"
                                        Duration="0:0:1"
                                        BeginTime="0:0:1"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                        <EventTrigger RoutedEvent="MouseEnter"
                                      SourceName="PART_VerticalScrollBar">
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation
                                        Storyboard.TargetName="PART_VerticalScrollBar"
                                        Storyboard.TargetProperty="Opacity"
                                        To="1"
                                        Duration="0:0:1"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                        <EventTrigger RoutedEvent="MouseLeave"
                                      SourceName="PART_VerticalScrollBar">
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation
                                        Storyboard.TargetName="PART_VerticalScrollBar"
                                        Storyboard.TargetProperty="Opacity"
                                        To="0"
                                        Duration="0:0:1"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                        <EventTrigger RoutedEvent="MouseEnter"
                                      SourceName="PART_HorizontalScrollBar">
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation
                                        Storyboard.TargetName="PART_HorizontalScrollBar"
                                        Storyboard.TargetProperty="Opacity"
                                        To="1"
                                        Duration="0:0:1"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                        <EventTrigger RoutedEvent="MouseLeave"
                                      SourceName="PART_HorizontalScrollBar">
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation
                                        Storyboard.TargetName="PART_HorizontalScrollBar"
                                        Storyboard.TargetProperty="Opacity"
                                        To="0"
                                        Duration="0:0:1"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>
View Code

 TabControl样式:

技术图片
<!--TabControl样式-->
<ControlTemplate x:Key="tmplTabControl" TargetType="TabControl" >
    <ControlTemplate.Resources>
        <Style TargetType="TabItem">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="TabItem">
                        <Border x:Name="bd" Margin="0 0 2 0" Background="Transparent" BorderThickness="1 1 1 0" BorderBrush="#035b72" CornerRadius="10 10 0 0">
                            <TextBlock x:Name="txt" Margin="20 0 20 0" Text="{TemplateBinding Header}" Foreground="#ddd" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="true">
                                <Setter TargetName="bd" Property="Background" Value="#045971"/>
                                <Setter TargetName="txt" Property="Foreground" Value="#fff"/>
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="true"></Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </ControlTemplate.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="26"></RowDefinition>
            <RowDefinition Height="1*"></RowDefinition>
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal" IsItemsHost="True" Background="Transparent"></StackPanel>
        <Border Grid.Row="1" Background="#045971">
            <ContentPresenter Content="{TemplateBinding Property=SelectedContent}">
            </ContentPresenter>
        </Border>
    </Grid>
</ControlTemplate>
View Code

TabControl样式效果图:

技术图片

 

WPF常用样式总结

标签:sse   put   auto   Nero   selected   convert   let   mic   tabs   

原文地址:https://www.cnblogs.com/s0611163/p/10583769.html

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