Adding Rows to RadGridView in ViewModel and enable scrolling

1 Answer 59 Views
GridView
Roland
Top achievements
Rank 1
Roland asked on 13 Jan 2025, 02:35 PM
Hi,

I am adding Rows to a RadGridView in the ViewModel while the View is displayed. When the RadGridView runs out of vertical Space, I would like the user to be able to scroll, but scrolling is not possible despite the Scrollbal being visible and Scrolling Enabled.


<telerik:RadGridView
    ScrollViewer.VerticalScrollBarVisibility="Visible"
    ScrollViewer.CanContentScroll="True"
    telerik:StyleManager.Theme="{StaticResource GreenTheme}"
    ItemsSource="{Binding FilteredMessages}"
    VerticalAlignment="Stretch"
    ScrollMode="RealTime"
    CanUserGroupColumns="False"
    IsReadOnly="True">
</telerik:RadGridView>

1 Answer, 1 is accepted

Sort by
1
Accepted
Martin Ivanov
Telerik team
answered on 16 Jan 2025, 11:27 AM

Hello Roland,

This happens when the RadGridView (or any other control in WPF that supports scrolling) is placed in a panel that measures its children with infinity size (as much size as its children need to draw all their contents). For example, a StackPanel or the Grid's RowDefinition with its Height set to Auto.

To properly enable scrolling you should place the corresponding control in a panel that measures its children with the available space. For example, a Grid panel with fixed or star size.

<Grid>
     <telerik:RadGridView />
</Grid>

Regards,
Martin Ivanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Roland
Top achievements
Rank 1
commented on 22 Jan 2025, 09:38 AM

Thanks,
after some fiddling around I got it to work.
The final Solution looks like this:

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <telerik:RadProgressBar x:Name="mainProgressBar"/>
        <telerik:RadProgressBar x:Name="subProgressBar"/>
        <telerik:RadGridView
            telerik:StyleManager.Theme="{StaticResource GreenTheme}"
            Grid.Row="3"
            IsReadOnly="True"
            ShowSearchPanel="True"
            ItemsSource="{Binding FilteredMessages}"
            RowStyleSelector="{StaticResource ReportProgressGridRowStyleSelector}"
            ScrollViewer.CanContentScroll="True"
            ScrollMode="RealTime"
            CanUserGroupColumns="False"
            ShowGroupPanel="False"/>
    </Grid>

Thanks for your Help!

Best Regards,
Roland
Tags
GridView
Asked by
Roland
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or