Change the foreground on mouse over

2 posts, 0 answers
  1. José Arthur
    José Arthur avatar
    2 posts
    Member since:
    Jun 2010

    Posted 02 Dec 2013 Link to this post

    How can I change the foreground and background of a row when the mouse is over the row?
  2. Yoan
    Admin
    Yoan avatar
    1068 posts

    Posted 05 Dec 2013 Link to this post

    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 >>
  3. DevCraft banner
Back to Top