Enabling Horizontal Scroll for Group Header in RadGridView
Environment
Product | RadGridView for WPF |
Version | 2024.3.924 |
Description
How to enable horizontal scrolling in the group header row of RadGridView for WPF.
Solution
By default the GroupHeaderRow element doesn't scroll horizontally. To allow this, you can set the SelectiveScrollingGrid.SelectiveScrollingOrientation
attached property on one of the visual children of the row.
You can do this by modifying the GroupHeaderRow's ControlTemplate or programmatically through the RowLoaded
event. Basically, you need to find the ToggleButton
element with x:Name="HeaderButton"
and set the attached property on it.
The following example shows how to use the RowLoaded
event.
private void gridView_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
{
if (e.Row is GroupHeaderRow)
{
var button = e.Row.ChildrenOfType<ToggleButton>()
.FirstOrDefault(x => Telerik.Windows.Controls.GridView.SelectiveScrollingGrid.GetSelectiveScrollingOrientation(x) == SelectiveScrollingOrientation.Vertical);
Telerik.Windows.Controls.GridView.SelectiveScrollingGrid.SetSelectiveScrollingOrientation(button, SelectiveScrollingOrientation.Both);
Telerik.Windows.Controls.GridView.SelectiveScrollingGrid.SetSelectiveScrollingClip(button, true);
}
}