You say: "All cells of both grids have no size specifications (Auto Sized)" - this is where the problem is. When the grid
cell is auto
sized the grid
gives the content in that cell as much space as it wants (doesn't matter if it fits in the window or not). To fix it you have to put your DataGrid
into a star-sized cell.
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Border Grid.Row="0">
<!-- Content that will take as much space as it wants -->
</Border>
<Border Grid.Row="1">
<!-- Content that will take all the remaining space -->
</Border>
</Grid>
UPDATE: Based on the screenshots you provided...
First, get rid of the DockPanel
in the top level control. DockPanel
gives its child all the space it asks for. If it is not a "fill" child (LastChildFill="True"
). Use grid
instead of DockPanel
(i.e. at the top level a grid
with two rows - one auto-sized for the menu and the second star-size for the rest of the stuff, the in that star-size row put another grid
for you items controls, etc.).
Remember, whenever you put the content either in an auto-size cell in a grid or in a DockPanel
with dock type different than Fill
, the content will take as much space as it required without showing a scroll bar (it will go beyond the window).
UPDATE 2: Looking at the new screenshots (see comments to this post)...
OK, I think I see the problem. The thing is that ItemsControl
uses StackPanel
to display its children, but StackPanel
also gives its children all the space they want (your DataGrid
thinks that it has enough space to render itself without scroll bars).
To fix that you need to put your items controls inside an ScrollViewer
like this:
<ScrollViewer VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto">
<ItemsControl ... />
</ScrollViewer>