-1

I have a GUI which looks like this:

<UserControl>
<ScrollViewer>
<Grid>
<dxg:GridControl>
</dxg:GridControl>
</Grid>
</ScrollViewer>
</UserControl>

The user control is in a ContentControl on my MainWdow.xaml. I would like the Grid to take the whole space available in the window and I would like the GridControl (devExpress) to not expand beyond the grid's height

Right now, I need to set a MaxHeight on the GridControl otherwise Devexpress throws an exception. If I put this MaxHeight to let's say 1500, the gridControl's height turns out to be greater than the Grid container and this latter resizes to accomodate the former.

I would like the grid to take as much space as possible without needing to show vertical scrollbar, and I would like the GridControl inside to take as much height possible within this Grid container and show a vertical scrollbar.

I can't for the life of me find a solution. Can you please suggest something?

ColVodori
  • 27
  • 2
  • Why do you have the ScrollViewer at all? It sounds like all you need is to remove it. Otherwise the Grid will become as large as its child elements want, i.e. the height necessary to show the whole GridControl content. – Clemens Aug 29 '23 at 06:40
  • In DevExpress try to use LayoutGroups and LayoutItems. In some cases you need to set max values. – Ugur Aug 30 '23 at 14:47

1 Answers1

-1

I have not acutally worked with Devexpress, but based on the following link https://supportcenter.devexpress.com/ticket/details/t593771/dealing-with-devexpress-xpf-grid-infinitegridsizeexception, this could work:

<Grid>
    <dxg:GridControl Height="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=ActualHeight}"
                     Width="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=ActualWidth}">
    </dxg:GridControl>
</Grid>
  • This makes no sense. A Grid will directly resize its child elements. The Binding is pointless. – Clemens Aug 29 '23 at 05:16
  • Grid does resize it's children when using standard controls, however size can be changed in custom controls, so rather then saying it makes no sense you could first test this and see, whether it helps. I had a very similar experience as the one described here with an OpenGL control in the past. – Adam Procházka Aug 29 '23 at 06:22
  • Could you look at the link, I mentioned in my solution? – Adam Procházka Aug 29 '23 at 06:35
  • You might have done something wrong then. Unless you fiddle with the alignments, A Grid will ultimately resize each kind of child element. A devexpress GridControl will obviously not explicitly set its own Width or Height. – Clemens Aug 29 '23 at 06:35
  • "*If you wish to adjust GridControl's height according to parent elements **that don't restrict** children's height, you can bind GridControl.Height to the ActualHeight property*" - a Grid does restrict the height of its child elements. – Clemens Aug 29 '23 at 06:37
  • Well it does not seem to restrict it since: "If I put this MaxHeight to let's say 1500, the **gridControl's height turns out to be greater than the Grid container**..." – Adam Procházka Aug 29 '23 at 06:43
  • That is certainly a wrong obervation or description. The Grid will be as high as its child element, since it is itself the child of a ScrollViewer. – Clemens Aug 29 '23 at 06:47