Monday, September 17, 2012

DataGrid Header Style in Silverlight 4.0

DataGrid Header Style in Silverlight 4.0

I want to set header of datagrid like following link.

Style in HeaderColumn in Datagrid

I have used DataGridColumnHeadersPresenter in my code.

See my following code:

   <Style x:Key="XYZ" TargetType="sdk:DataGridColumnHeadersPresenter" >          <Setter Property="Template">             <Setter.Value>                 <ControlTemplate TargetType="sdk:DataGridRowGroupHeader">                     <Border x:Name="ButtonBorder"                          CornerRadius="0,0,0,0"                          BorderThickness="0"                           BorderBrush="Transparent">                         <Border.Background>                             <LinearGradientBrush StartPoint="0,0" EndPoint="1">                                 <GradientBrush.GradientStops>                                     <GradientStopCollection>                                         <GradientStop Color="#555" Offset="0.0"/>                                         <GradientStop Color="#000" Offset="0.8"/>                                     </GradientStopCollection>                                 </GradientBrush.GradientStops>                             </LinearGradientBrush>                         </Border.Background>                         <ItemsPresenter/>                     </Border>                 </ControlTemplate>             </Setter.Value>         </Setter>     </Style>     <Style x:Key="BreakGridStyle" TargetType="sdk:Datagird">         <Setter Property="HeadersVisibility" Value="Column" />         <Setter Property="AutoGenerateColumns" Value="False" />         <Setter Property="Width" Value="Auto" />                    <Setter Property="Template">             <Setter.Value>                 <ControlTemplate TargetType="sdk:DataGrid">                     <Grid>                         <StackPanel>                             <sdk:DataGridColumnHeadersPresenter Name="ABC" Style="{StaticResource XYZ}" />                             <ItemsPresenter/>                         </StackPanel>                     </Grid>                 </ControlTemplate>             </Setter.Value>         </Setter>     </Style> 

But i got following Error:

The property 'Template' was not found in type 'System.Windows.Controls.Primitives.DataGridColumnHeadersPresenter'.

How to solve this and how to achieve my datagrid's column style as in above link

Answers & Comments...




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog