Blue Theme Orange Theme Green Theme Red Theme
 
Home | Forums | Videos | Photos | Blogs | Beginners | Advertise with Us
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
Nevron Gauge for SharePoint
Search :       Advanced Search »
Home » WPF » WPF DataGrid Style

WPF DataGrid Style

The DataGrid control provides a flexible way to display a collection of data in rows and columns. The DataGrid includes built-in column types and a template column for hosting custom content. The built-in row type includes a drop-down details section that you can use to display additional content below the cell values.

Author Rank :
Page Views : 26588
Downloads : 1220
Rating :
 Rate it
Level : Beginner
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
Download Files:
WpfDataGridStyle.zip
 
 
Team Foundation Server Hosting
Become a Sponsor
 Tag Cloud
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 



The DataGrid control provides a flexible way to display a collection of data in rows and columns. The DataGrid includes built-in column types and a template column for hosting custom content. The built-in row type includes a drop-down details section that you can use to display additional content below the cell values.

Here is a simple style for WPF DataGrid that I want to share with all.

Style features:

  1. Rounded Border
  2. Gradient DataGridColumnHeader with MouseOver effect
  3. Custom ValidationErrorTemplate
  4. DataGridRow MouseOver effect
  5. DataGridCell IsSelected effect

1.png

 

<!--DataGrid -->

    <!--Style and template for the resize control on the DataGridColumnHeader.-->

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

        <Setter Property="Width" Value="5" />

        <Setter Property="Background" Value="Transparent" />

        <Setter Property="Cursor" Value="SizeWE" />

        <Setter Property="Template">

            <Setter.Value>

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

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

                </ControlTemplate>

            </Setter.Value>

        </Setter>

    </Style>

 

    <!--Style and template for the DataGridColumnHeader.-->

    <Style TargetType="{x:Type DataGridColumnHeader}">

        <Setter Property="Background" Value="{DynamicResource NormalBorderBrush}"/>

        <Setter Property="Foreground" Value="{DynamicResource TextBrush}"/>

        <Setter Property="VerticalContentAlignment" Value="Center" />

        <Setter Property="Height" Value="30"/>

        <Setter Property="SeparatorBrush" Value="#FFC9CACA" />

        <Setter Property="FontSize" Value="14"/>

        <Setter Property="FontWeight" Value="SemiBold"/>

        <Setter Property="Padding" Value="4 0 0 0"/>

        <Setter Property="Template">

            <Setter.Value>

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

                    <ControlTemplate.Resources>

                        <Storyboard x:Key="HoverOn">

                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Hover" Storyboard.TargetProperty="(UIElement.Opacity)">

                                <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1"/>

                            </DoubleAnimationUsingKeyFrames>

                        </Storyboard>

                        <Storyboard x:Key="HoverOff">

                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Hover" Storyboard.TargetProperty="(UIElement.Opacity)">

                                <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0" />

                            </DoubleAnimationUsingKeyFrames>

                        </Storyboard>

                    </ControlTemplate.Resources>

                    <Grid Background='Transparent' >

                        <Grid.ColumnDefinitions>

                            <ColumnDefinition Width='Auto' />

                            <ColumnDefinition Width='Auto' />

                            <ColumnDefinition Width='*' />

                            <ColumnDefinition Width='Auto' />

                        </Grid.ColumnDefinitions>

                        <Rectangle x:Name="BackgroundRectangle" Grid.ColumnSpan="4" Grid.RowSpan="2"

                                   Fill="{StaticResource NormalBrush}" Stretch="Fill" Stroke="{StaticResource NormalBorderBrush}" StrokeThickness="1" />

                        <Rectangle x:Name="Hover" Grid.ColumnSpan="4" Grid.RowSpan="2" Stretch="Fill"

                                   Fill="{StaticResource MouseOverBrush}" Opacity="0" />

                        <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"

                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"

                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"

                                                  Margin='{TemplateBinding Padding}'

                                                  Cursor="{TemplateBinding Cursor}"/>

                        <Path HorizontalAlignment="Left" x:Name="SortArrow" VerticalAlignment="Center"

                                      Width="8" Opacity="0" RenderTransformOrigin=".5,.5" Grid.Column="2" Grid.RowSpan="2" Fill="#FF000000" Stretch="Uniform" Data="F1 M -5.215,6.099L 5.215,6.099L 0,0L -5.215,6.099 Z ">

                            <Path.RenderTransform>

                                <TransformGroup>

                                    <ScaleTransform ScaleX=".9" ScaleY=".9" x:Name="SortIconTransform" />

                                </TransformGroup>

                            </Path.RenderTransform>

                        </Path>

                        <Thumb x:Name="PART_LeftHeaderGripper" Grid.Column="0" HorizontalAlignment="Left" Style="{StaticResource ColumnHeaderGripperStyle}"/>

                        <Thumb x:Name="PART_RightHeaderGripper" Grid.Column="3" HorizontalAlignment="Right" Style="{StaticResource ColumnHeaderGripperStyle}"/>

                    </Grid>

                    <ControlTemplate.Triggers>

                        <Trigger Property="SortDirection" Value="Ascending">

                            <Setter TargetName="SortArrow" Property="Opacity" Value="1" />

                            <Setter TargetName="SortArrow" Property="RenderTransform">

                                <Setter.Value>

                                    <RotateTransform Angle="180" />

                                </Setter.Value>

                            </Setter>

                            <Setter TargetName="BackgroundRectangle" Property="Opacity" Value="1" />

                        </Trigger>

                        <Trigger Property="SortDirection" Value="Descending">

                            <Setter TargetName="SortArrow" Property="Opacity" Value="1" />

                            <Setter TargetName="BackgroundRectangle" Property="Opacity" Value="1" />

                        </Trigger>

                        <Trigger Property="IsMouseOver" Value="true">

                            <Trigger.EnterActions>

                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>

                            </Trigger.EnterActions>

                            <Trigger.ExitActions>

                                <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>

                            </Trigger.ExitActions>

                        </Trigger>

                    </ControlTemplate.Triggers>

                </ControlTemplate>

            </Setter.Value>

        </Setter>       

    </Style>

 

    <!--Style and template for the DataGridColumnHeadersPresenter.-->

    <Style TargetType="{x:Type DataGridColumnHeadersPresenter}">

        <Setter Property="Template">

            <Setter.Value>

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

                    <Grid>

                        <DataGridColumnHeader x:Name="PART_FillerColumnHeader" IsHitTestVisible="False" />

                        <ItemsPresenter />

                    </Grid>

                </ControlTemplate>

            </Setter.Value>

        </Setter>

    </Style>

 

    <Style x:Key="{ComponentResourceKey ResourceId=DataGridSelectAllButtonStyle, TypeInTargetAssembly={x:Type DataGrid}}" TargetType="{x:Type Button}">

        <Setter Property="Template">

            <Setter.Value>

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

                    <Grid>

                        <Rectangle x:Name="Border" Fill="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" SnapsToDevicePixels="True"/>

                        <Polygon x:Name="Arrow" Fill="Black" HorizontalAlignment="Right" Margin="8,8,3,3" Opacity="0.15" Points="0,10 10,10 10,0" Stretch="Uniform" VerticalAlignment="Bottom"/>

                    </Grid>

                    <ControlTemplate.Triggers>

                        <Trigger Property="IsMouseOver" Value="True">

                            <Setter Property="Stroke" TargetName="Border" Value="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}"/>

                        </Trigger>

                        <Trigger Property="IsPressed" Value="True">

                            <Setter Property="Fill" TargetName="Border" Value="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}"/>

                        </Trigger>

                        <Trigger Property="IsEnabled" Value="False">

                            <Setter Property="Visibility" TargetName="Arrow" Value="Collapsed"/>

                        </Trigger>

                    </ControlTemplate.Triggers>

                </ControlTemplate>

            </Setter.Value>

        </Setter>

    </Style>

 

    <Style TargetType="{x:Type DataGrid}">

        <Setter Property="Background" Value="{StaticResource ControlContentBrush}"/>

        <Setter Property="RowDetailsVisibilityMode" Value="VisibleWhenSelected"/>

        <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>

        <Setter Property="ScrollViewer.PanningMode" Value="Both"/>

        <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>

        <Setter Property="Margin" Value="5"/>

        <Setter Property="BorderBrush" Value="{StaticResource NormalBorderBrush}" />

        <Setter Property="AlternatingRowBackground" Value="{StaticResource AlternateBackgroundBrush}"/>

        <Setter Property="HorizontalGridLinesBrush" Value="{StaticResource NormalBorderBrush}"/>

        <Setter Property="VerticalGridLinesBrush" Value="{StaticResource NormalBorderBrush}"/>

        <Setter Property="Template">

            <Setter.Value>

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

                    <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="2" CornerRadius="5" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True">

                        <ScrollViewer x:Name="DG_ScrollViewer" Focusable="false">

                            <ScrollViewer.Template>

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

                                    <Grid>

                                        <Grid.ColumnDefinitions>

                                            <ColumnDefinition Width="Auto"/>

                                            <ColumnDefinition Width="*"/>

                                            <ColumnDefinition Width="Auto"/>

                                        </Grid.ColumnDefinitions>

                                        <Grid.RowDefinitions>

                                            <RowDefinition Height="Auto"/>

                                            <RowDefinition Height="*"/>

                                            <RowDefinition Height="Auto"/>

                                        </Grid.RowDefinitions>

                                        <Button Command="{x:Static DataGrid.SelectAllCommand}" Focusable="false" Style="{DynamicResource {ComponentResourceKey ResourceId=DataGridSelectAllButtonStyle, TypeInTargetAssembly={x:Type DataGrid}}}" Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.All}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" Width="{Binding CellsPanelHorizontalOffset, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>

                                        <DataGridColumnHeadersPresenter x:Name="PART_ColumnHeadersPresenter" Grid.Column="1" Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Column}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>

                                        <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" Grid.ColumnSpan="2" Grid.Row="1"/>

                                        <ScrollBar x:Name="PART_VerticalScrollBar" Grid.Column="2" Maximum="{TemplateBinding ScrollableHeight}" Orientation="Vertical" Grid.Row="1" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}"/>

                                        <Grid Grid.Column="1" Grid.Row="2">

                                            <Grid.ColumnDefinitions>

                                                <ColumnDefinition Width="{Binding NonFrozenColumnsViewportHorizontalOffset, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>

                                                <ColumnDefinition Width="*"/>

                                            </Grid.ColumnDefinitions>

                                            <ScrollBar x:Name="PART_HorizontalScrollBar" Grid.Column="1" Maximum="{TemplateBinding ScrollableWidth}" Orientation="Horizontal" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportWidth}"/>

                                        </Grid>

                                    </Grid>

                                </ControlTemplate>

                            </ScrollViewer.Template>

                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>

                        </ScrollViewer>

                    </Border>

                </ControlTemplate>

            </Setter.Value>

        </Setter>

        <Style.Triggers>

            <Trigger Property="IsGrouping" Value="true">

                <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>

            </Trigger>

        </Style.Triggers>

    </Style>

 

    <Style TargetType="{x:Type DataGridRow}">

        <Setter Property="SnapsToDevicePixels" Value="true"/>

        <Setter Property="Validation.ErrorTemplate" Value="{x:Null}"/>

        <Setter Property="ValidationErrorTemplate">

            <Setter.Value>

                <ControlTemplate>

                    <Grid>

                        <Ellipse Width="12" Height="12" Margin="0 2 0 0"

                        Fill="Red" Stroke="Black" VerticalAlignment="Top"

                        StrokeThickness="0.5"/>

                        <TextBlock FontWeight="Bold" Padding="4,0,0,0"

                        VerticalAlignment="Top" Foreground="White" Text="!"

                        ToolTip="{Binding (Validation.Errors)[0].ErrorContent, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGridRow}}}"/>

                    </Grid>

                </ControlTemplate>

            </Setter.Value>

        </Setter>

 

        <Setter Property="Template">

            <Setter.Value>

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

                    <ControlTemplate.Resources>

                        <Storyboard x:Key="SelectedOn">

                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="select_gradient" Storyboard.TargetProperty="(UIElement.Opacity)">

                                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1" />

                            </DoubleAnimationUsingKeyFrames>

                        </Storyboard>

                        <Storyboard x:Key="SelectedOff">

                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="select_gradient" Storyboard.TargetProperty="(UIElement.Opacity)">

                                <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0" />

                            </DoubleAnimationUsingKeyFrames>

                        </Storyboard>

                        <Storyboard x:Key="HoverOn">

                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="hover_gradient" Storyboard.TargetProperty="(UIElement.Opacity)">

                                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="0.85" />

                            </DoubleAnimationUsingKeyFrames>

                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="highlight" Storyboard.TargetProperty="(UIElement.Opacity)">

                                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="0.65" />

                            </DoubleAnimationUsingKeyFrames>

                        </Storyboard>

                        <Storyboard x:Key="HoverOff">

                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="hover_gradient" Storyboard.TargetProperty="(UIElement.Opacity)">

                                <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0" />

                            </DoubleAnimationUsingKeyFrames>

                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="highlight" Storyboard.TargetProperty="(UIElement.Opacity)">

                                <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0" />

                            </DoubleAnimationUsingKeyFrames>

                        </Storyboard>

                    </ControlTemplate.Resources>

                    <Border x:Name="DGR_Border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">

                        <SelectiveScrollingGrid>

                            <SelectiveScrollingGrid.ColumnDefinitions>

                                <ColumnDefinition Width="Auto"/>

                                <ColumnDefinition Width="*"/>

                            </SelectiveScrollingGrid.ColumnDefinitions>

                            <SelectiveScrollingGrid.RowDefinitions>

                                <RowDefinition Height="*"/>

                                <RowDefinition Height="Auto"/>

                            </SelectiveScrollingGrid.RowDefinitions>

 

                            <Rectangle x:Name="hover_gradient" Stroke="{DynamicResource FocusBrush}" StrokeThickness="1" RadiusX="1" RadiusY="1" Opacity="0" IsHitTestVisible="False" Grid.Column="1" Fill="{DynamicResource MouseOverBrush}"/>

                            <Rectangle x:Name="highlight" Margin="1" StrokeThickness="1" RadiusX="0.5" RadiusY="0.5" Opacity="0" IsHitTestVisible="False" Grid.Column="1" Stroke="{DynamicResource MouseOverHighlightBrush}" Fill="{DynamicResource MouseOverHighlightBrush}"/>

                            <Rectangle x:Name="select_gradient" Grid.Row="0" Grid.ColumnSpan="2" StrokeThickness="1" RadiusX="1" RadiusY="1" Opacity="0" IsHitTestVisible="False" Fill="{DynamicResource PressedBrush}" Stroke="{DynamicResource PressedBorderBrush}"/>

 

                            <DataGridCellsPresenter Grid.Column="1" ItemsPanel="{TemplateBinding ItemsPanel}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>

                            <DataGridDetailsPresenter Grid.Column="1" Grid.Row="1" SelectiveScrollingGrid.SelectiveScrollingOrientation="{Binding AreRowDetailsFrozen, ConverterParameter={x:Static SelectiveScrollingOrientation.Vertical}, Converter={x:Static DataGrid.RowDetailsScrollingConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" Visibility="{TemplateBinding DetailsVisibility}"/>

                            <DataGridRowHeader Grid.RowSpan="2" SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical" Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Row}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>

 

                        </SelectiveScrollingGrid>

                    </Border>

                    <ControlTemplate.Triggers>

                        <Trigger Property="IsMouseOver" Value="True" SourceName="DGR_Border">

                            <Trigger.ExitActions>

                                <BeginStoryboard Storyboard="{StaticResource HoverOff}" x:Name="HoverOff_BeginStoryboard" />

                            </Trigger.ExitActions>

                            <Trigger.EnterActions>

                                <BeginStoryboard Storyboard="{StaticResource HoverOn}" x:Name="HoverOn_BeginStoryboard" />

                            </Trigger.EnterActions>

                        </Trigger>

                        <Trigger Property="IsSelected" Value="true">

                            <Trigger.ExitActions>

                                <BeginStoryboard x:Name="SelectedOff_BeginStoryboard" Storyboard="{StaticResource SelectedOff}" />

                            </Trigger.ExitActions>

                            <Trigger.EnterActions>

                                <BeginStoryboard Storyboard="{StaticResource SelectedOn}" />

                            </Trigger.EnterActions>

                        </Trigger>

                    </ControlTemplate.Triggers>

                </ControlTemplate>

            </Setter.Value>

        </Setter>

    </Style>

 

    <Style TargetType="{x:Type DataGridCell}">

        <Setter Property="Template">

            <Setter.Value>

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

                    <ControlTemplate.Resources>

                        <Storyboard x:Key="SelectedOn">

                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="select_gradient" Storyboard.TargetProperty="(UIElement.Opacity)">

                                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1" />

                            </DoubleAnimationUsingKeyFrames>

                        </Storyboard>

                        <Storyboard x:Key="SelectedOff">

                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="select_gradient" Storyboard.TargetProperty="(UIElement.Opacity)">

                                <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0" />

                            </DoubleAnimationUsingKeyFrames>

                        </Storyboard>

                    </ControlTemplate.Resources>

                    <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">

                        <Grid>

                            <Rectangle x:Name="select_gradient" Margin="-2 -1 -2 -1"  Grid.Column="1" StrokeThickness="1" RadiusX="1" RadiusY="1" Opacity="0" IsHitTestVisible="False" Fill="{DynamicResource PressedBrush}" Stroke="{DynamicResource PressedBorderBrush}"/>

                            <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>

                        </Grid>

                    </Border>

                    <ControlTemplate.Triggers>

                        <Trigger Property="IsSelected" Value="true">

                            <Trigger.ExitActions>

                                <BeginStoryboard x:Name="SelectedOff_BeginStoryboard" Storyboard="{StaticResource SelectedOff}" />

                            </Trigger.ExitActions>

                            <Trigger.EnterActions>

                                <BeginStoryboard Storyboard="{StaticResource SelectedOn}" />

                            </Trigger.EnterActions>

                        </Trigger>

                    </ControlTemplate.Triggers>

                </ControlTemplate>

 

            </Setter.Value>

        </Setter>

    </Style>

    <BooleanToVisibilityConverter x:Key="bool2VisibilityConverter"/>

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

        <Setter Property="Height" Value="8"/>

        <Setter Property="Background" Value="Transparent"/>

        <Setter Property="Cursor" Value="SizeNS"/>

        <Setter Property="Template">

            <Setter.Value>

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

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

                </ControlTemplate>

            </Setter.Value>

        </Setter>

    </Style>

 

    <Style TargetType="{x:Type DataGridRowHeader}">

        <Setter Property="Width" Value="20"/>

        <Setter Property="Template">

            <Setter.Value>

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

                    <Grid>

                        <Microsoft_Windows_Themes:DataGridHeaderBorder BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" IsPressed="{TemplateBinding IsPressed}" IsHovered="{TemplateBinding IsMouseOver}" IsSelected="{TemplateBinding IsRowSelected}" Orientation="Horizontal" Padding="{TemplateBinding Padding}" SeparatorBrush="{TemplateBinding SeparatorBrush}" SeparatorVisibility="{TemplateBinding SeparatorVisibility}">

                            <StackPanel Orientation="Horizontal">

                                <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center"/>

                                <Control SnapsToDevicePixels="false" Template="{Binding ValidationErrorTemplate, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}}" Visibility="{Binding (Validation.HasError), Converter={StaticResource bool2VisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}}"/>

                            </StackPanel>

                        </Microsoft_Windows_Themes:DataGridHeaderBorder>

                        <Thumb x:Name="PART_TopHeaderGripper" Style="{StaticResource RowHeaderGripperStyle}" VerticalAlignment="Top"/>

                        <Thumb x:Name="PART_BottomHeaderGripper" Style="{StaticResource RowHeaderGripperStyle}" VerticalAlignment="Bottom"/>

                    </Grid>

                </ControlTemplate>

            </Setter.Value>

        </Setter>    </Style>



Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
Login to add your contents and source code to this article
 [Top] Rate this article
 
 About the author
 
Author
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
 
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
 Comments
good style by Jacky On January 7, 2011
like it
Reply | Email | Modify 
Really Nice by Khaniya On January 28, 2011
Thanks for sharing it
Reply | Email | Modify 
Team Foundation Server Hosting
 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.