RadGridView gets huge for no reason

2 posts, 0 answers
  1. Lukas
    Lukas avatar
    20 posts
    Member since:
    Jul 2011

    Posted 03 Dec 2012 Link to this post

    Hello Telerik,

    I've got a bit of a fight with your GridView/TreeListView.
    We use your GridView as a search grid, which dynamically resizes, as soon as the user resizes the whole window. The RadGridView is held by a ContentControl.

    Sometimes the Grid appears far too wide. We couldn't figure out whether it depends on the data or the Xaml (maybe something else?). Yes, I know it's better if you use the RadGrid with fixed height and width for performance, but the requirement, that the grid resizes with the application size, must be met. Since there isn't that much data shown in our grids (10-20 rows max), we really don't need the performance boost of virtualization.

    I debugged the construction of the visual tree and every control measures alright, except the RadGridView. I read a lot in your documentation, where was told, that measuring the RadGridView with double.PositiveInfinity might cause performance issues, but it should be possible, shouldn't it? However, the RadGridView is measured with double.PositiveInfinity either ways and returns a DesiredSize.Width of 60.000 pixles. How is this possible? And the GridView is shown really, really buggy. It's split in a couple of parts in horizontal direction. Firstly theres a Grid, which contains all its columns. Then about a 1000 pixles margin, then an empty Grid, which is huge, space again and finally another empty Grid. All of them contain the right amount of rows, though.

    Here's code of a Grid, which is shown wrong sometimes.

    <Grid Grid.Row="1"
                <RowDefinition />
                <RowDefinition Height="Auto" />
            <telerik:RadGridView x:Name="SearchGrid"
                         AlternateRowBackground="{StaticResource B4Brush}"
                         ItemsSource="{Binding SearchManager.FoundItems}"
                         SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
                    <telerik:GridViewDataColumn Width="5*"
                            <StackPanel Margin="0 8">
                                <TextBlock FontWeight="Bold"
                                     Foreground="{Binding TitelFarbe, Mode=TwoWay}"
                                     Text="{Binding SearchItemMasterEntity.FieldArr[0]}" />
                                <TextBlock MaxHeight="{Binding DataContext.MaxTextHeight, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=telerik:RadTreeListView}}"
                                     Text="{Binding SearchItemMasterEntity.FieldArr[1]}"
                                     TextWrapping="Wrap" />
                    <i:EventTrigger EventName="RowActivated">
                        <cal:ActionMessage MethodName="DoEdit" />
               <Button x:Name="SearchMore"
                Content="{Binding TL[SearchControl.More]}" />
            <TextBox x:Name="TextBoxResultNumbers"
                 Text="{Binding SearchManager.SearchResultNumbers}" />

    I'd really like to reproduce the issue in a sample project, but I can't figure out how. I appreciate every advice of you, which might solve this problem.

    Kind regards

    edit: I found out something else, which seems pretty strange to me. If I start the application in OOB mode, the RadGridViews usually show up the right way. But if I start the app in the browser almost every Grid gets measured huge. Might this be caused by a ScrollViewer? I think the browser window is just a big ScrollViewer, isn't it?

    edit2: another update. When I remove every ScrollViewer in our visual tree, the RadGridViews are really just as big as their parent is. But as soon as I reactivate the ScrollViewer, the Grids get huge again. Do you know what causes this?
  2. Vlad
    Vlad avatar
    11100 posts

    Posted 04 Dec 2012 Link to this post


     Your requirement to resize RadGridView with the parent container can be met if you use Grid layout. Using components like ScrollViewer, StackPanel, Canvas, etc. cannot fit in such scenario since they will measure all child controls with infinity height and width.

    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top