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?
6 Answers, 1 is accepted
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.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Can you share sample where it works for you?
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 >>
Thanks,
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.
Maya
Telerik
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.