This is a migrated thread and some comments may be shown as answers.

Change the foreground on mouse over

1 Answer 26 Views
GridView
This is a migrated thread and some comments may be shown as answers.
José Arthur
Top achievements
Rank 1
José Arthur asked on 02 Dec 2013, 12:12 PM
How can I change the foreground and background of a row when the mouse is over the row?

1 Answer, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 05 Dec 2013, 04:05 PM
Hi José,

If you want to modify the appearance of the selected row, you can predefine its template. There you should modify the Border element named Background_Selected in the way you need. I can suggest you to check this help article for a reference.

If you want to change GridViewCells foreground when its parent row is hovered/selected you should predefine the template of GridViewRow and access DataCellsPresenter. You should add an additional animation to the default hover/selection states of a row and manipulate the Foreground property of DataCellsPresenter, as follows:

Mouse Over state:
<VisualState x:Name="MouseOver">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="Background_Over"
                                        Storyboard.TargetProperty="(UIElement.Visibility)">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <Visibility>Visible</Visibility>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_DataCellsPresenter"
                                        Storyboard.TargetProperty="Foreground">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0"
                                            Value="{StaticResource GridView_ItemForeground_Over}" />
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>


Selected state:
<VisualState x:Name="Selected">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="Background_Selected"
                                        Storyboard.TargetProperty="(UIElement.Visibility)">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <Visibility>Visible</Visibility>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="NavigatorIndicatorBackground"
                                        Storyboard.TargetProperty="Background">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0"
                                            Value="{StaticResource GridView_RowIndicatorCellBackground_Selected}" />
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_DataCellsPresenter"
                                        Storyboard.TargetProperty="Foreground">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0"
                                            Value="{StaticResource GridView_ItemForeground_Selected}" />
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>



Regards,
Yoan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
José Arthur
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Share this question
or