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

How to auto resize a gridview within a content control?

3 Answers 1168 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 26 Mar 2015, 03:27 PM
We have a WPF application using prism and regions.

The Shell looks like this.

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
    </Grid.ColumnDefinitions>
 
    <billingCustomControls:BillingToaster Margin="0,0,-490,0" />
 
    <ContentControl Grid.Row="0"
                    HorizontalContentAlignment="Stretch"
                    VerticalContentAlignment="Stretch"
                    prism:RegionManager.RegionName="{x:Static pll:RegionNames.BannerRegion}"
                    VerticalAlignment="Top" />
 
    <Grid Grid.Row="1">
 
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
 
        <StackPanel Grid.Column="0">
 
            <ContentControl Margin="0"
                            HorizontalContentAlignment="Stretch"
                            VerticalContentAlignment="Stretch"
                            prism:RegionManager.RegionName="{x:Static pll:RegionNames.UserDetailsRegion}" />
 
            <Separator />
 
            <ItemsControl Margin="0"
                          HorizontalContentAlignment="Stretch"
                          VerticalContentAlignment="Stretch"
                          prism:RegionManager.RegionName="{x:Static pll:RegionNames.TaskBarRegion}" />
 
            <ContentControl Margin="0"
                            HorizontalContentAlignment="Stretch"
                            VerticalContentAlignment="Stretch"
                            MinHeight="200"
                            MinWidth="100"
                            prism:RegionManager.RegionName="{x:Static pll:RegionNames.FooterRegion}"
                            VerticalAlignment="Bottom" />
 
        </StackPanel>
 
        <Grid Grid.Column="1">
 
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
 
            <ContentControl Grid.Row="0"
                            HorizontalContentAlignment="Stretch"
                            VerticalContentAlignment="Stretch"
                            Margin="2,2,2,2"
                            prism:RegionManager.RegionName="{x:Static pll:RegionNames.MenuBarRegion}" />
 
            <ContentControl Grid.Row="1"
                            HorizontalContentAlignment="Stretch"
                            VerticalContentAlignment="Stretch"
                            Margin="2,2,2,6"
                            prism:RegionManager.RegionName="{x:Static pll:RegionNames.BreadCrumbRegion}" />
 
            <ContentControl Grid.Row="2"
                            HorizontalAlignment="Stretch"
                            VerticalAlignment="Stretch"
                            HorizontalContentAlignment="Stretch"
                            VerticalContentAlignment="Stretch"
                            Margin="2,2,2,2"
                            prism:RegionManager.RegionName="{x:Static pll:RegionNames.WorkSpaceRegion}" />
 
        </Grid>
 
    </Grid>
 
</Grid>

We load a user control in the WorkSpaceRegion which contains a RadGridView.

But when the grid is displayed it always has the maximum width needed to display the entire grid.

How can we get the RadGridView to autosize so that it takes the available width of the main window instead of running of the screen?

Regards,
Peter

3 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 30 Mar 2015, 09:06 AM
Hi Peter,

Would you try placing RadGridView in a Grid with RowDefinition.Height="*"? In that way the control should fill all the available space only, displaying a horizontal scrollbar so that all the columns to be visible. In order you would like to have all the columns displayed in the view area, then I can suggest you configuring RadGridView with ColumnWidth="*". 

Regards,
Dimitrina
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Peter
Top achievements
Rank 1
answered on 30 Mar 2015, 12:27 PM
Hi Dimitrina,

Thanks for the response. The GridView is already defined in a Grid Row with Height=* so that was not the solution.

It turned out to be not a problem with the gridview in a content control but an issue with RadDocking. After examining the Telerik RadDocking example I now use a RadDocking.DocumentHost to host the gridview. This works as we want it to so this problem is solved :)

Next problem is that we want to get rid of the header and border of the radpane(or group or document host). But I will post that in a new thread to keep seperation of problems :)

Thanks and regards,
Peter



0
Dimitrina
Telerik team
answered on 30 Mar 2015, 12:28 PM
Hi Peter,

Thank you very much for sharing your solution with the community.

Regards,
Dimitrina
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

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