Sign In|Join
Home/Silverlight.NET Forums/General Silverlight Programming/Silverlight Controls and Silverlight Toolkit/DataGrid ColumnStyle question
Last post Oct 23, 2008 04:48 AM by WadeFlextronics
Participant
1300 Points
312 Posts
Oct 17, 2008 12:32 AM | LINK
Hi folks,
I have problem with the DataGrid styling because I couldn't find the place where I can style the remaining space after the last colums in the header. Just have a look at my screenshot and you can easily see what the problem is.
http://pvrzqw.bay.livefilestore.com/y1pdJj04Jgsd-17o9fp6UfAU3F8uAGcnYzQGYqQkatZVkyI8Y6D_MjfrthBoi5cyGVTJZiob9_q10o/DataGridStyling.JPG
1694 Points
261 Posts
Microsoft
Oct 18, 2008 01:54 PM | LINK
Hi,
Is this RC0? This bug has been fixed in RTW build. Please give it a try.
Oct 18, 2008 11:48 PM | LINK
I thought I have the RTW version. Here is the version number of my SL installation : 2.0.31005.0
Cheers
Jan
Oct 19, 2008 02:08 AM | LINK
Yes. This should be the RTW version. Do you mind to post your style? Did you restyle it by using the ColumnHeaderStyle?
Oct 19, 2008 06:09 AM | LINK
Yes I'm using a ColumnHeaderStyle.
Here the code:
Style x:Key="DarkDataGridColumnHeaderStyle" TargetType="System_Windows_Controls_Primitives:DataGridColumnHeader"> <Setter Property="Foreground" Value="#FFE2E2E2"/> <Setter Property="HorizontalContentAlignment" Value="Center"/> <Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="FontSize" Value="10.5"/> <Setter Property="FontWeight" Value="Bold"/> <Setter Property="IsTabStop" Value="False"/> <Setter Property="SeparatorBrush" Value="#FFC5C5C5"/> <Setter Property="Padding" Value="4,4,5,4"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="System_Windows_Controls_Primitives:DataGridColumnHeader"> <Grid x:Name="Root"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="*"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualStateGroup.Transitions> <VisualTransition GeneratedDuration="00:00:0.1"/> </VisualStateGroup.Transitions> <VisualState x:Name="Normal"/> <VisualState x:Name="MouseOver"> <Storyboard> <ColorAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetName="BackgroundRectangle" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"> <SplineColorKeyFrame KeyTime="0" Value="#FF448DCA"/> </ColorAnimationUsingKeyFrames> <ColorAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)"> <SplineColorKeyFrame KeyTime="0" Value="#7FFFFFFF"/> </ColorAnimationUsingKeyFrames> <ColorAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)"> <SplineColorKeyFrame KeyTime="0" Value="#CCFFFFFF"/> </ColorAnimationUsingKeyFrames> <ColorAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)"> <SplineColorKeyFrame KeyTime="0" Value="#F2FFFFFF"/> </ColorAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> <VisualStateGroup x:Name="SortStates"> <VisualStateGroup.Transitions> <VisualTransition GeneratedDuration="00:00:0.1"/> </VisualStateGroup.Transitions> <VisualState x:Name="Unsorted"/> <VisualState x:Name="SortAscending"> <Storyboard> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="SortIcon" Storyboard.TargetProperty="Opacity"> <SplineDoubleKeyFrame KeyTime="0" Value="1.0"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </VisualState> <VisualState x:Name="SortDescending"> <Storyboard> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="SortIcon" Storyboard.TargetProperty="Opacity"> <SplineDoubleKeyFrame KeyTime="0" Value="1.0"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="SortIconTransform" Storyboard.TargetProperty="ScaleY"> <SplineDoubleKeyFrame KeyTime="0" Value="-.9"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Rectangle x:Name="BackgroundRectangle" Grid.ColumnSpan="2" Grid.RowSpan="2" Fill="Black" Stretch="Fill"/> <Rectangle x:Name="BackgroundGradient" Grid.ColumnSpan="2" Grid.RowSpan="2" Stretch="Fill"> <Rectangle.Fill> <!--<LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0"> <GradientStop Color="#A1FFFFFF" Offset="0.015"/> <GradientStop Color="#F9FFFFFF" Offset="0.375"/> <GradientStop Color="#E5FFFFFF" Offset="0.6"/> <GradientStop Color="#C6FFFFFF" Offset="1"/> </LinearGradientBrush>--> <LinearGradientBrush EndPoint="0.7,1" StartPoint="0.7,0"> <GradientStop Color="#FFA3AEB9"/> <GradientStop Color="#FF8399A9" Offset="0.375"/> <GradientStop Color="#FF718597" Offset="0.375"/> <GradientStop Color="#FF000000" Offset="1"/> </LinearGradientBrush> </Rectangle.Fill> </Rectangle> <ContentPresenter Cursor="{TemplateBinding Cursor}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Grid.RowSpan="2" Content="{TemplateBinding Content}"/> <Rectangle x:Name="VerticalSeparator" VerticalAlignment="Stretch" Width="1" Visibility="{TemplateBinding SeparatorVisibility}" Grid.Column="2" Grid.RowSpan="2" Fill="{TemplateBinding SeparatorBrush}"/> <Path HorizontalAlignment="Left" x:Name="SortIcon" VerticalAlignment="Center" Width="8" Opacity="0" RenderTransformOrigin=".5,.5" Grid.Column="1" Grid.RowSpan="2" Fill="#FF444444" 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> </Grid> </ControlTemplate> </Setter.Value> </Setter> <Setter Property="Background" Value="{x:Null}"/> </Style>
Member
377 Points
82 Posts
Oct 23, 2008 04:48 AM | LINK
This may help from the breaking changes document found here: http://blogs.msdn.com/silverlight_sdk/archive/2008/10/10/silverlight-breaking-changes-between-beta-2-and-release-updated-document.aspx
Summary
Visuals cannot be duplicated so they cannot be used for the Header property due to column reordering.
To put visuals in column headers, users will need to template the column header to include the visual instead of setting it as the Header.
<data:DataGridTextColumn DisplayMemberBinding=”{Binding FirstName}”>
<data:DataGridTextColumn.Header>
<Button Content=”hello” />
</data:DataGridTextColumn.Header>
</data:DataGridTextColumn>
<data:DataGridTextColumn Binding="{Binding LastName}" Header="hello">
<data:DataGridTextColumn.HeaderStyle>
<Style TargetType="dataprimitives:DataGridColumnHeader">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Button Content="{TemplateBinding Content}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</data:DataGridTextColumn.HeaderStyle>
(Please mark as Answered if this helps)
bitdisaster
Participant
1300 Points
312 Posts
DataGrid ColumnStyle question
Oct 17, 2008 12:32 AM | LINK
Hi folks,
I have problem with the DataGrid styling because I couldn't find the place where I can style the remaining space after the last colums in the header. Just have a look at my screenshot and you can easily see what the problem is.
http://pvrzqw.bay.livefilestore.com/y1pdJj04Jgsd-17o9fp6UfAU3F8uAGcnYzQGYqQkatZVkyI8Y6D_MjfrthBoi5cyGVTJZiob9_q10o/DataGridStyling.JPG
Research Associate University of Victoria
Please remember to mark the replies as answers if they answered your question
xusun
Participant
1694 Points
261 Posts
Microsoft
Re: DataGrid ColumnStyle question
Oct 18, 2008 01:54 PM | LINK
Hi,
Is this RC0? This bug has been fixed in RTW build. Please give it a try.
Xun Sun - MSFT
bitdisaster
Participant
1300 Points
312 Posts
Re: Re: DataGrid ColumnStyle question
Oct 18, 2008 11:48 PM | LINK
I thought I have the RTW version. Here is the version number of my SL installation : 2.0.31005.0
Cheers
Jan
Research Associate University of Victoria
Please remember to mark the replies as answers if they answered your question
xusun
Participant
1694 Points
261 Posts
Microsoft
Re: Re: DataGrid ColumnStyle question
Oct 19, 2008 02:08 AM | LINK
Yes. This should be the RTW version. Do you mind to post your style? Did you restyle it by using the ColumnHeaderStyle?
Xun Sun - MSFT
bitdisaster
Participant
1300 Points
312 Posts
Re: Re: Re: DataGrid ColumnStyle question
Oct 19, 2008 06:09 AM | LINK
Yes I'm using a ColumnHeaderStyle.
Here the code:
Style x:Key="DarkDataGridColumnHeaderStyle" TargetType="System_Windows_Controls_Primitives:DataGridColumnHeader">
<Setter Property="Foreground" Value="#FFE2E2E2"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="FontSize" Value="10.5"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="SeparatorBrush" Value="#FFC5C5C5"/>
<Setter Property="Padding" Value="4,4,5,4"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="System_Windows_Controls_Primitives:DataGridColumnHeader">
<Grid x:Name="Root">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="00:00:0.1"/>
</VisualStateGroup.Transitions>
<VisualState x:Name="Normal"/>
<VisualState x:Name="MouseOver">
<Storyboard>
<ColorAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetName="BackgroundRectangle" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
<SplineColorKeyFrame KeyTime="0" Value="#FF448DCA"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)">
<SplineColorKeyFrame KeyTime="0" Value="#7FFFFFFF"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)">
<SplineColorKeyFrame KeyTime="0" Value="#CCFFFFFF"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
<SplineColorKeyFrame KeyTime="0" Value="#F2FFFFFF"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="SortStates">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="00:00:0.1"/>
</VisualStateGroup.Transitions>
<VisualState x:Name="Unsorted"/>
<VisualState x:Name="SortAscending">
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="SortIcon" Storyboard.TargetProperty="Opacity">
<SplineDoubleKeyFrame KeyTime="0" Value="1.0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="SortDescending">
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="SortIcon" Storyboard.TargetProperty="Opacity">
<SplineDoubleKeyFrame KeyTime="0" Value="1.0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="SortIconTransform" Storyboard.TargetProperty="ScaleY">
<SplineDoubleKeyFrame KeyTime="0" Value="-.9"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Rectangle x:Name="BackgroundRectangle" Grid.ColumnSpan="2" Grid.RowSpan="2" Fill="Black" Stretch="Fill"/>
<Rectangle x:Name="BackgroundGradient" Grid.ColumnSpan="2" Grid.RowSpan="2" Stretch="Fill">
<Rectangle.Fill>
<!--<LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0">
<GradientStop Color="#A1FFFFFF" Offset="0.015"/>
<GradientStop Color="#F9FFFFFF" Offset="0.375"/>
<GradientStop Color="#E5FFFFFF" Offset="0.6"/>
<GradientStop Color="#C6FFFFFF" Offset="1"/>
</LinearGradientBrush>-->
<LinearGradientBrush EndPoint="0.7,1" StartPoint="0.7,0">
<GradientStop Color="#FFA3AEB9"/>
<GradientStop Color="#FF8399A9" Offset="0.375"/>
<GradientStop Color="#FF718597" Offset="0.375"/>
<GradientStop Color="#FF000000" Offset="1"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<ContentPresenter Cursor="{TemplateBinding Cursor}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Grid.RowSpan="2" Content="{TemplateBinding Content}"/>
<Rectangle x:Name="VerticalSeparator" VerticalAlignment="Stretch" Width="1" Visibility="{TemplateBinding SeparatorVisibility}" Grid.Column="2" Grid.RowSpan="2" Fill="{TemplateBinding SeparatorBrush}"/>
<Path HorizontalAlignment="Left" x:Name="SortIcon" VerticalAlignment="Center" Width="8" Opacity="0" RenderTransformOrigin=".5,.5" Grid.Column="1" Grid.RowSpan="2" Fill="#FF444444" 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>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Background" Value="{x:Null}"/>
</Style>
Research Associate University of Victoria
Please remember to mark the replies as answers if they answered your question
WadeFlextronics
Member
377 Points
82 Posts
Re: Re: Re: Re: DataGrid ColumnStyle question
Oct 23, 2008 04:48 AM | LINK
This may help from the breaking changes document found here: http://blogs.msdn.com/silverlight_sdk/archive/2008/10/10/silverlight-breaking-changes-between-beta-2-and-release-updated-document.aspx
DataGridColumn.Header no longer supports visuals
Who Is Affected: Silverlight 2 Beta 2 managed applications that use the DataGrid.Summary
Visuals cannot be duplicated so they cannot be used for the Header property due to column reordering.
Fix RequiredTo put visuals in column headers, users will need to template the column header to include the visual instead of setting it as the Header.
Beta 2[Xaml]<data:DataGridTextColumn DisplayMemberBinding=”{Binding FirstName}”>
<data:DataGridTextColumn.Header>
<Button Content=”hello” />
</data:DataGridTextColumn.Header>
</data:DataGridTextColumn>
RTM[Xaml]<data:DataGridTextColumn Binding="{Binding LastName}" Header="hello">
<data:DataGridTextColumn.HeaderStyle>
<Style TargetType="dataprimitives:DataGridColumnHeader">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Button Content="{TemplateBinding Content}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</data:DataGridTextColumn.HeaderStyle>
</data:DataGridTextColumn>
(Please mark as Answered if this helps)
Thanks,
Wade