Hi,
I want to change the foreground color of the row when it is selected.(Its black under normal circumstances and needs to be changed to white when the row is selected)
I could not find any way to do this. I was able to set the background color but could not really set the foreground color. Can you provide me a way to do this.
Thanks,
This is a follow up, if you have any further questions in this topic please feel free to reply.
Thank you,Sam
Your reply didn't answer the exact question, which is how to change the cellcontrol foreground color. The foreground color property is not exposed in the cell control content presenter.
Hello,
Here is an example of retemplating the CellControl with Foreground style:
Style
<Style x:Key="cellStyle" TargetType="ig:CellControl">
<Setter Property="Foreground" Value="Red"/>
</Style>
Column
<ig:XamGrid.Columns>
<ig:TextColumn Key="ProductID" AllowToolTips="Always" CellStyle="{StaticResource cellStyle}"/>
...
Let me know if you have any questions.
I had the same problem and abandoned setting the CellStyle of the active row, as was previously suggested in other postings. There were some strange side effects, such as the Alternate Row background color getting lost until you mouse over it. What I did was set the following xaml on the grid
<igGrid:XamGrid.SelectionSettings>
<igGrid:SelectionSettings RowSelection="Single" CellClickAction="SelectRow" CellSelection="None"/>
</igGrid:XamGrid.SelectionSettings>
Then, I overrode the CellControl style with the following.
<Style TargetType="ig:CellControl">
<Setter Property="FontSize" Value="11" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Background" Value="{StaticResource CellItemNormalBackgroundBrush}"/>
<Setter Property="BorderBrush" Value="{StaticResource CellItemNormalBorderBrush}"/>
<Setter Property="BorderThickness" Value="0,0,1,0"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="Padding" Value="5"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ig:CellControl">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="MouseOver">
<Storyboard >
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00" Storyboard.TargetName="AltMouseOver" Storyboard.TargetProperty="Fill">
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{StaticResource GridRowHoverBrush}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Alternate" >
<Storyboard>
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{StaticResource CellItemAltNormalBackgroundBrush}"/>
</VisualStateGroup>
<VisualStateGroup x:Name="SelectedStates">
<VisualState x:Name="NotSelected" />
<VisualState x:Name="Selected">
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00" Storyboard.TargetName="ActiveSelected" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{StaticResource GridRowSelectedBrush}"/>
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00" Storyboard.TargetName="ActiveSelected" Storyboard.TargetProperty="BorderThickness">
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="0,0,1,0"/>
<VisualStateGroup x:Name="ActiveStates">
<VisualState x:Name="InActive" />
<VisualState x:Name="Active">
<!--<Storyboard >
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="1"/>
</Storyboard>-->
</VisualStateManager.VisualStateGroups>
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" x:Name="Root"/>
<Rectangle x:Name="AltMouseOver" Margin="{TemplateBinding BorderThickness}"/>
<Border x:Name="ActiveSelected" BorderBrush="{StaticResource CellItemNormalBorderBrush}"></Border>
<ContentPresenter VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
Hope this helps someone, I certainly toiled at this for long enough.
-greg