This question is locked. New answers and comments are not allowed.
Hi,
I'm trying to implement the ExpandAllGroups() / CollapseAllGroups() functionality with a ToggleButton inside the GridView.
I have modified the ControlTemplate for the GridViewHeaderIndentCell and placed a ToggleButton there.
I have also managed to implement the graphics for it (I use the same arrow as in the GridViewGroupRowTemplate) and it rotates 180 degrees when toggled. (See attached image).
But how can I get an event from it so I can call the ExpandAllGroups() / CollapseAllGroups() methods?
Or can I connect a command to it somehow?
I have my own implementation of the grid that inherits from RadGridView if that would make it easier?
I can't add a click event in the template because it the template is in a separate resourcefile with no code behind.
I tried to find the button in OnApplyTemplate() using GetTemplateChild() but it does not exist at that moment, not until the data is loaded and grouped.
Here is my template:
Regards,
HÃ¥kan
I'm trying to implement the ExpandAllGroups() / CollapseAllGroups() functionality with a ToggleButton inside the GridView.
I have modified the ControlTemplate for the GridViewHeaderIndentCell and placed a ToggleButton there.
I have also managed to implement the graphics for it (I use the same arrow as in the GridViewGroupRowTemplate) and it rotates 180 degrees when toggled. (See attached image).
But how can I get an event from it so I can call the ExpandAllGroups() / CollapseAllGroups() methods?
Or can I connect a command to it somehow?
I have my own implementation of the grid that inherits from RadGridView if that would make it easier?
I can't add a click event in the template because it the template is in a separate resourcefile with no code behind.
I tried to find the button in OnApplyTemplate() using GetTemplateChild() but it does not exist at that moment, not until the data is loaded and grouped.
Here is my template:
<
ControlTemplate
TargetType
=
"telerik:GridViewHeaderIndentCell"
>
<
Border
BorderBrush
=
"{TemplateBinding BorderBrush}"
BorderThickness
=
"{TemplateBinding BorderThickness}"
HorizontalAlignment
=
"{TemplateBinding HorizontalContentAlignment}"
Padding
=
"{TemplateBinding Padding}"
VerticalAlignment
=
"{TemplateBinding VerticalContentAlignment}"
Width
=
"25"
>
<
ToggleButton
x:Name
=
"ExpandAllButton"
Width
=
"20"
Height
=
"20"
Margin
=
"0"
VerticalAlignment
=
"Center"
HorizontalAlignment
=
"Center"
>
<
ToggleButton.Template
>
<
ControlTemplate
TargetType
=
"ToggleButton"
>
<
Grid
>
<
VisualStateManager.VisualStateGroups
>
<
VisualStateGroup
x:Name
=
"CommonStates"
>
<
VisualState
x:Name
=
"Normal"
/>
<
VisualState
x:Name
=
"MouseOver"
/>
<
VisualState
x:Name
=
"Pressed"
/>
<
VisualState
x:Name
=
"Disabled"
/>
</
VisualStateGroup
>
<
VisualStateGroup
x:Name
=
"CheckStates"
>
<
VisualState
x:Name
=
"Checked"
>
<
Storyboard
>
<
DoubleAnimationUsingKeyFrames
BeginTime
=
"00:00:00"
Storyboard.TargetProperty
=
"(UIElement.RenderTransform).(RotateTransform.Angle)"
Storyboard.TargetName
=
"Arrow"
>
<
EasingDoubleKeyFrame
KeyTime
=
"00:00:00.2"
Value
=
"180"
/>
</
DoubleAnimationUsingKeyFrames
>
</
Storyboard
>
</
VisualState
>
<
VisualState
x:Name
=
"Unchecked"
>
<
Storyboard
>
<
DoubleAnimationUsingKeyFrames
BeginTime
=
"00:00:00"
Storyboard.TargetProperty
=
"(UIElement.RenderTransform).(RotateTransform.Angle)"
Storyboard.TargetName
=
"Arrow"
>
<
EasingDoubleKeyFrame
KeyTime
=
"00:00:00.2"
Value
=
"0"
/>
</
DoubleAnimationUsingKeyFrames
>
</
Storyboard
>
</
VisualState
>
</
VisualStateGroup
>
<
VisualStateGroup
x:Name
=
"FocusStates"
>
<
VisualState
x:Name
=
"Focused"
/>
<
VisualState
x:Name
=
"Unfocused"
/>
</
VisualStateGroup
>
</
VisualStateManager.VisualStateGroups
>
<
Path
x:Name
=
"Arrow"
Data
=
"M0,0L1,0 2,0 2,0.99999991 3,0.99999991 3,2 4,2 4,0.99999991 5,0.99999991 5,0 5.9999999,0 7,0 7,0.99999991 5.9999999,0.99999991 5.9999999,2 5,2 5,3 4,3 4,4 3,4 3,3 2,3 2,2 1,2 1,0.99999991 0,0.99999991z"
Fill
=
"Black"
Height
=
"5"
Width
=
"7"
Margin
=
"5"
RenderTransformOrigin
=
"0.5,0.5"
HorizontalAlignment
=
"Center"
VerticalAlignment
=
"Center"
>
<
Path.RenderTransform
>
<
RotateTransform
/>
</
Path.RenderTransform
>
</
Path
>
</
Grid
>
</
ControlTemplate
>
</
ToggleButton.Template
>
</
ToggleButton
>
</
Border
>
</
ControlTemplate
>
Regards,
HÃ¥kan