How to auto resize a gridview within a content control?

4 posts, 0 answers
  1. Peter
    Peter avatar
    10 posts
    Member since:
    Feb 2015

    Posted 26 Mar 2015 Link to this post

    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
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 30 Mar 2015 Link to this post

    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.

     
  3. Peter
    Peter avatar
    10 posts
    Member since:
    Feb 2015

    Posted 30 Mar 2015 Link to this post

    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



  4. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 30 Mar 2015 Link to this post

    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.

     
Back to Top