GridView within a GridView sizing issues

4 posts, 1 answers
  1. Hilary
    Hilary avatar
    5 posts
    Member since:
    Oct 2014

    Posted 22 Oct 2014 Link to this post

    I have a GridView (WPF 4.5, Q2 2013) that has another GridView in its RowDetailsTemplate. When I set the width to "*" on any columns of the second RadGridView, the DetailsPresenter gets extremely long (about 10000 px), even though I only have two columns that should fit on the screen.

    I found a strange solution: in a new style for RadGridView, if I wrap the GridViewVirtualizingPanel in a Grid and apply it to "SecondGridView" in the RowDetailsTemplate, the columns size normally. I am hesitant to do this because I don't understand why it works; is there a better way?

    Here is what I am working with, where the columns get really long:

    <DataTemplate x:Key="MyRowDetailsTemplate" >
            <Border >
                <controls3:RadGridView x:Name="SecondGridView" ItemsSource="{Binding MoreItems}">
                        <controls3:RadGridView.Columns>
                            <controls3:GridViewDataColumn Width="*"
                                                          MinWidth="200"
                                                          Header="Name" />
                            <controls3:GridViewDataColumn Width="75"
                                                          MinWidth="75"
                                                          Header="Status" />
                        </controls3:RadGridView.Columns>
                    </controls3:RadGridView>
            </Border>
        </DataTemplate>
     
    <controls:RadGridView Name="TemplateRoot"
                                          ItemsSource="{Binding MyItems}"
                                          RowDetailsTemplate="{DynamicResource MyRowDetailsTemplate}">
                        <controls:RadGridView.Columns>
                            <controls:GridViewDataColumn Width="*"
                                                         MinWidth="200"
                                                         Header="Name"/>
                            <controls:GridViewDataColumn Width="75"
                                                         MinWidth="75"
                                                         Header="Status"/>
                        </controls:RadGridView.Columns>
    </controls:RadGridView>
  2. Answer
    Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 23 Oct 2014 Link to this post

    Hello,

    RadGridView's RowDetails are measured with infinity, which leads to the result you observe. What you may do is to set the Width/ MaxWidth of the grid defined in RowDetailsTemplate.

    Regards,
    Dimitrina
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. Hilary
    Hilary avatar
    5 posts
    Member since:
    Oct 2014

    Posted 23 Oct 2014 in reply to Dimitrina Link to this post

    Thanks, Dimitrina, that helped! However, it doesn't resize properly. When I make the window larger, the columns do expand; however, when I make it smaller, they do not adjust and instead I get a scrollbar. This is what I set on my inner GridView, which is inside a DockPanel:

    Width="{Binding ActualWidth,
                  RelativeSource={RelativeSource AncestorType={x:Type DockPanel}},
                  UpdateSourceTrigger=PropertyChanged}"
  4. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 24 Oct 2014 Link to this post

    Hello,

    Мay I ask you to attach a demo project illustrating your implementation? You can also take a look at this blog post for a reference on how to isolate an issue. That way we can check it locally and advise further.

    You can open a new support thread and attach the project there.

    Regards,
    Dimitrina
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top