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

Expanding the Grid Width

1 Answer 51 Views
This is a migrated thread and some comments may be shown as answers.
Terry Newton
Top achievements
Rank 1
Terry Newton asked on 22 Apr 2011, 07:02 PM
I am having trouble expanding the width to match the dialog.

After various attempts I tried the hammer of explicetly setting it from code behind



Private Sub dlg_TimeGridBase_SizeChanged(ByVal sender As Object, ByVal e As System.Windows.SizeChangedEventArgs) Handles Me








Me.grdContent.Width = e.NewSize.Width - Me.grdContent.Margin.Left - Me









Me.stkContent.Width = Me.grdContent.Width - Me.stkContent.Margin.Left - Me









Me.grdRows.Width = Me.stkContent.Width - Me.grdRows.Margin.Left - Me











The Grid is nested within a stackpanel within the layout grid.  The problem is that this seems to set the values well, but the width of the gid is still limited to the width it was initially rendered at as a maximum and I still can not expand it beyond that width.

I did try binding it in the xaml, but no matter what I do it does not seem to want to fill out the width wider than a fixed amount I have no clue about. 




any suggestions?  I want the grid to resize up its width with when the dialog size is widened no matter how big the user makes it.  I do observe that the right portion (beyond the initially displayed window) never appears, but seems to be accounted for in the horizontal scrollbar, and as I expand the width past my initial width the vertical scrollbar disapears from view, but reappears when I reduce the width below the initial display width.  Its as if there is a mask over the right hand side of the grid starting where the initial width first displayed with a higher z-order that prevents viewing that portion of the grid.

1 Answer, 1 is accepted

Sort by
Vanya Pavlova
Telerik team
answered on 23 Apr 2011, 01:33 PM
Hi Terry,


Generally RadGridView is auto-sized by default, which means that its default Width/Height properties are set to Auto. If you need to adjust it when resizing relative to its container you do not have to specify anything special. Imagine that you have a window which does not have a fixed size, just arrange RadGridView and its container in an appropriate manner, as shown below:

<Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource SampleDataSource}}">
<telerik:RadGridView ItemsSource="{Binding Collection}"/>
Each time you resize this window, RadGridView's width will be adjusted to the width of the container.
Furthermore you mentioned that RadGridView is placed in a StackPanel, which is not preferrable. The StackPanel is a layout control which measures its children with infinity and that is the reason by which you lose the scrollbars. 

Best wishes,
Vanya Pavlova
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Asked by
Terry Newton
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Share this question