首页 > 代码库 > GridViewColumnHeader样式

GridViewColumnHeader样式

<LinearGradientBrush x:Key="GridViewColumnHeaderBorderBackground" StartPoint="0,0" EndPoint="0,1">

     <LinearGradientBrush.GradientStops>

         <GradientStop Color="#FFF2F2F2" Offset="0" />

         <GradientStop Color="#FFD5D5D5" Offset="1" />

     </LinearGradientBrush.GradientStops>

 </LinearGradientBrush>

 <LinearGradientBrush x:Key="GridViewColumnHeaderBackground" StartPoint="0,0" EndPoint="0,1">

     <LinearGradientBrush.GradientStops>   

       <GradientStop Color="#FFFFFFFF" Offset="0" />  

        <GradientStop Color="#FFFFFFFF" Offset="0.4091" />   

       <GradientStop Color="#FFF7F8F9" Offset="1" />  

    </LinearGradientBrush.GradientStops>  </LinearGradientBrush>

 <LinearGradientBrush x:Key="GridViewColumnHeaderHoverBackground" StartPoint="0,0" EndPoint="0,1">    

  <LinearGradientBrush.GradientStops>   

       <GradientStop Color="#FFBDEDFF" Offset="0" />      

    <GradientStop Color="#FFB7E7FB" Offset="1" />

     </LinearGradientBrush.GradientStops>

 </LinearGradientBrush>

 <LinearGradientBrush x:Key="GridViewColumnHeaderPressBackground" StartPoint="0,0" EndPoint="0,1">    

  <LinearGradientBrush.GradientStops>   

       <GradientStop Color="#FF8DD6F7" Offset="0" />

         <GradientStop Color="#FF8AD1F5" Offset="1" />   

   </LinearGradientBrush.GradientStops>

 </LinearGradientBrush>

 <Style x:Key="GridViewColumnHeaderGripper"          TargetType="{x:Type Thumb}">    

  <Setter Property="Canvas.Right" Value="http://www.mamicode.com/-9" />    

  <Setter Property="Width" Value="http://www.mamicode.com/18" />  

    <Setter Property="Height" Value="http://www.mamicode.com/{Binding Path=ActualHeight,RelativeSource={RelativeSource TemplatedParent}}" />   

   <Setter Property="Padding" Value="http://www.mamicode.com/0" />

     <Setter Property="Background" Value="http://www.mamicode.com/White" />   

   <Setter Property="Template">

         <Setter.Value>        

      <ControlTemplate TargetType="{x:Type Thumb}">      

            <Border Padding="{TemplateBinding Padding}"   Background="Transparent">    

                  <Rectangle HorizontalAlignment="Center" Width="1" Fill="{TemplateBinding Background}" />    

              </Border>

             </ControlTemplate>

         </Setter.Value>

     </Setter>  

</Style>

 <Style x:Key="GridViewColumnHeader" TargetType="{x:Type GridViewColumnHeader}">   

   <Setter Property="HorizontalContentAlignment" Value="http://www.mamicode.com/Center" />

     <Setter Property="VerticalContentAlignment" Value="http://www.mamicode.com/Center" />

     <Setter Property="Background" Value="http://www.mamicode.com/{StaticResource GridViewColumnHeaderBackground}" />  

    <Setter Property="BorderBrush" Value="http://www.mamicode.com/{StaticResource GridViewColumnHeaderBorderBackground}" />

     <Setter Property="BorderThickness" Value="http://www.mamicode.com/0" />   

   <Setter Property="Padding" Value="http://www.mamicode.com/2,0,2,0" />  

    <Setter Property="Foreground" Value="http://www.mamicode.com/{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />   

   <Setter Property="Template">

         <Setter.Value>        

      <ControlTemplate TargetType="{x:Type GridViewColumnHeader}">     

             <Grid SnapsToDevicePixels="true">            

          <Border Name="HeaderBorder" BorderThickness="0,1,0,1" BorderBrush="{TemplateBinding BorderBrush}"    Background="{TemplateBinding Background}">         

                 <Grid>             

                 <Grid.RowDefinitions>

<RowDefinition MaxHeight="7" />  

                                <RowDefinition />    

                          </Grid.RowDefinitions>     

                         <Rectangle Name="UpperHighlight" Visibility="Collapsed" Fill="#FFE3F7FF" />         

                     <Border Grid.RowSpan="2" Padding="{TemplateBinding Padding}">     

                             <ContentPresenter Name="HeaderContent"  Margin="0,0,0,1" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"                                   RecognizesAccessKey="True"   SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />  

                            </Border>

                         </Grid>        

              </Border>       

               <Border Name="HeaderHoverBorder" BorderThickness="1,0,1,1" Margin="1,1,0,0" />

                     <Border Name="HeaderPressBorder" BorderThickness="1,1,1,0" Margin="1,0,0,1" />     

                 <Canvas>                     

     <Thumb x:Name="PART_HeaderGripper"  Style="{StaticResource GridViewColumnHeaderGripper}" />        

              </Canvas>            

      </Grid>       

           <ControlTemplate.Triggers>       

               <Trigger Property="IsMouseOver" Value="http://www.mamicode.com/true">     

                     <Setter TargetName="HeaderBorder" Property="Background" Value="http://www.mamicode.com/{StaticResource GridViewColumnHeaderHoverBackground}" />   

                       <Setter TargetName="HeaderHoverBorder" Property="BorderBrush" Value="http://www.mamicode.com/#FF88CBEB" />        

                  <Setter TargetName="UpperHighlight" Property="Visibility" Value="http://www.mamicode.com/Visible" />     

                     <Setter TargetName="PART_HeaderGripper" Property="Background" Value="http://www.mamicode.com/Transparent" />             

         </Trigger>                

      <Trigger Property="IsPressed" Value="http://www.mamicode.com/true">     

                     <Setter TargetName="HeaderBorder" Property="Background" Value="http://www.mamicode.com/{StaticResource GridViewColumnHeaderPressBackground}" />       

                   <Setter TargetName="HeaderHoverBorder" Property="BorderBrush" Value="http://www.mamicode.com/#FF95DAF9" />            

              <Setter TargetName="HeaderPressBorder" Property="BorderBrush" Value="http://www.mamicode.com/#FF7A9EB1" />       

                   <Setter TargetName="UpperHighlight" Property="Visibility" Value="http://www.mamicode.com/Visible" />   

                       <Setter TargetName="UpperHighlight" Property="Fill" Value="http://www.mamicode.com/#FFBCE4F9" />      

                    <Setter TargetName="PART_HeaderGripper" Property="Visibility" Value="http://www.mamicode.com/Hidden" />       

                   <Setter TargetName="HeaderContent" Property="Margin" Value="http://www.mamicode.com/1,1,0,0" />       

               </Trigger>            

          <Trigger Property="Height" Value="http://www.mamicode.com/Auto">          

                <Setter Property="MinHeight" Value="http://www.mamicode.com/20" />        

              </Trigger>            

          <Trigger Property="IsEnabled" Value="http://www.mamicode.com/false">         

                 <Setter Property="Foreground" Value="http://www.mamicode.com/{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />     

                 </Trigger>           

       </ControlTemplate.Triggers>        

      </ControlTemplate>  

        </Setter.Value>

     </Setter>     

<Style.Triggers>  

        <Trigger Property="Role" Value="http://www.mamicode.com/Floating">      

        <Setter Property="Opacity" Value="http://www.mamicode.com/0.4082" />  

            <Setter Property="Template">        

          <Setter.Value>        

              <ControlTemplate TargetType="{x:Type GridViewColumnHeader}">    

                      <Canvas Name="PART_FloatingHeaderCanvas">          

                    <Rectangle Opacity="0.4697" Fill="#FF000000"                                  Width="{TemplateBinding ActualWidth}" Height="{TemplateBinding ActualHeight}" />            

              </Canvas>   

                   </ControlTemplate>        

          </Setter.Value>      

        </Setter>   

       </Trigger>   

       <Trigger Property="Role" Value="http://www.mamicode.com/Padding">        

      <Setter Property="Template">         

         <Setter.Value>           

           <ControlTemplate TargetType="{x:Type GridViewColumnHeader}">            

              <Border Name="HeaderBorder"                                  BorderThickness="0,1,0,1"                                  BorderBrush="{TemplateBinding BorderBrush}"                                  Background="{TemplateBinding Background}" />                

          <ControlTemplate.Triggers>           

                   <Trigger Property="Height" Value="http://www.mamicode.com/Auto">             

                     <Setter Property="MinHeight" Value="http://www.mamicode.com/20" />          

                    </Trigger>                  

        </ControlTemplate.Triggers>         

             </ControlTemplate>           

       </Setter.Value>      

        </Setter>        

  </Trigger>     

</Style.Triggers>

 </Style>