This is a migrated thread and some comments may be shown as answers.

GridView within a GridView sizing issues

3 Answers 64 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Hilary
Top achievements
Rank 1
Hilary asked on 22 Oct 2014, 09:19 PM
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>

3 Answers, 1 is accepted

Sort by
0
Accepted
Dimitrina
Telerik team
answered on 23 Oct 2014, 10:59 AM
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.

 
0
Hilary
Top achievements
Rank 1
answered on 23 Oct 2014, 09:25 PM
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}"
0
Dimitrina
Telerik team
answered on 24 Oct 2014, 08:26 AM
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.

 
Tags
GridView
Asked by
Hilary
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Hilary
Top achievements
Rank 1
Share this question
or