WPF DataGrid Scroll Bar

I am trying to do a WPF DataGrid scrollbar scroll when necessary. Below you can see the basic XAML code of my user control:

<Grid x:Name="Data" Grid.Column="0" VerticalAlignment="Stretch" Height="Auto" HorizontalAlignment="Stretch"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Expander Header="Route Setup" Grid.Row="0" VerticalAlignment="Top" Background="White"> </Expander> <Expander Header="Select Locations" Grid.Row="1" VerticalAlignment="Top" Background="White"> </Expander> <DataGrid Grid.Row="2" ItemsSource="{Binding Locations, Mode=TwoWay}" Height="Auto" AutoGenerateColumns="False" ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto"> </DataGrid> 

This does not work, I do not see any scroolbars when the DataGrid goes beyond the available space. I have already tried using scrollview around my DataGrid, but that does not change anything.

Update

It may be important to know that usercontrol is loaded into the LeftRegion shell, which has the following markup:

  <Grid x:Name="LayoutRoot"> <Grid.ColumnDefinitions > <ColumnDefinition Width="*" MinWidth="400" MaxWidth="600"/> <ColumnDefinition Width="9" /> <ColumnDefinition Width="*" MinWidth="300" /> </Grid.ColumnDefinitions> <GridSplitter x:Name="MainSplitter" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="1" Margin="0" Width="9" Style="{DynamicResource gridSplitterVerticalStyle}"/> <ItemsControl Name="LeftRegion" Grid.Column="0" Background="Azure" Height="Auto" VerticalAlignment="Stretch" VerticalContentAlignment="Stretch" cal:RegionManager.RegionName="LeftRegion"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Grid/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> <ItemsControl Name="RightRegion" Height="Auto" Background="DarkGreen" VerticalAlignment="Stretch" VerticalContentAlignment="Stretch" Grid.Column="2" cal:RegionManager.RegionName="RightRegion"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Grid/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> </Grid> 

Best wishes

Jay

+4
source share
2 answers

In your grid named Data, remove Height="Auto" from the third RowDefinition . At least one line must have a height of "*" (default) to take up the remaining free space.

+11
source

I decided. I needed to remove Height="Auto" from the RowDefinition file.

0
source

All Articles