Pressed VisualState for GridViewHeaderCell

7 posts, 0 answers
  1. Sergey
    Sergey avatar
    21 posts
    Member since:
    Aug 2012

    Posted 14 Sep 2011 Link to this post

    Hello!
    I try to customize style for GridViewHeaderCell. I created template for it and it works fine. But I'm surprized that it have no "Pressed" visual state. I want to change background of header of GridView when it pressed. Any ideas how I can do it?
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 16 Sep 2011 Link to this post

    Hi Sergey,

    Actually, the pressed state of GridViewHeaderCell is the selected one. So, you may try to edit the "_Selected" elements of its template. Please take a look at our online documentation for a reference.

     

    Greetings,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. Sergey
    Sergey avatar
    21 posts
    Member since:
    Aug 2012

    Posted 16 Sep 2011 Link to this post

    Selected state doesn't works.
    Can you share sample where it works for you?
  4. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 16 Sep 2011 Link to this post

    Hello Sergey,

    I am sending you a sample project illustrating how you may change the background of a GridViewHeaderCell when it is selected. You mainly need to edit the following part:

    <Border x:Name="GridViewHeaderCell_Selected" BorderBrush="{StaticResource GridView_HeaderOuterBorder_Selected}" BorderThickness="{TemplateBinding BorderThickness}" Grid.ColumnSpan="2" Opacity="0">
                        <Border BorderBrush="{StaticResource GridView_HeaderInnerBorder_Selected}" BorderThickness="1" Background="{StaticResource GridView_HeaderBackground_Selected}"/>
                    </Border>
     

    Kind regards,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  5. Sergey
    Sergey avatar
    21 posts
    Member since:
    Aug 2012

    Posted 20 Sep 2011 Link to this post

    ok, thanks
  6. Karan
    Karan avatar
    2 posts
    Member since:
    Jan 2013

    Posted 10 Jun 2013 Link to this post

    I have the same question Maya. Is there a way to change a header background color only when the mouse is in the down position (pressed position)? I am looking for something similar to what is described in this article: http://msdn.microsoft.com/en-us/library/ms742286(v=vs.85).aspx, but for a silverlight project.

    Thanks,

    Karan
  7. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 13 Jun 2013 Link to this post

    Hi Karan,

    Such behavior in Silverlight will require more code and customization that in WPF. You need to create your own custom state (for pressed position of the header), handle MouseLeftButtonDown event, call GoToState method of VisualStateManager to invoke the state you want. However, you will need to handle MouseLeftButtonUp event and return the state of the header to is default one when it is clicked - sorted in descending, ascending or none state.

    Regards,
    Maya
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top