Sam
Sam

Reputation: 45

Vertical scrollbar on multiple grids

I've three Windows Datagrids placed one below another on my XAML screen.Each of these grids have different column and rows(6 rows,5 rows and 4 rows respectively). I need to be able to show these grid contents in such a way so that no vertical scrollbar appears on any of these three grids.

If I don't put ScrollViewer.VerticalScrollBarVisibility="Visible" on the first grid,row number 6 becomes outside of the visibility area.

What am I missing here please?

 <ScrollViewer VerticalScrollBarVisibility="Auto" CanContentScroll="False">
        <Grid>


 <DataGrid Name="Grid1" Grid.Row="1" AutoGenerateColumns="False" CanUserAddRows="False" IsReadOnly="true"   
                              ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}" Margin="0,7,0,20" ColumnWidth="*"  ScrollViewer.VerticalScrollBarVisibility="Visible">


 <DataGrid Name="Grid2" Grid.Row="2" AutoGenerateColumns="False" CanUserAddRows="False" IsReadOnly="true" 
                              ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}" Margin="0,5,0,22" 
                           ScrollViewer.CanContentScroll="True" 
      ScrollViewer.HorizontalScrollBarVisibility="Visible">



<DataGrid Name="Grid3" Grid.Row="3" AutoGenerateColumns="False" CanUserAddRows="False" IsReadOnly="true" 
                              ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}" Margin="0,5,0,22" 
                           ScrollViewer.CanContentScroll="True"       
      ScrollViewer.HorizontalScrollBarVisibility="Visible">

</ScrollViewer>
</Grid>

Thanks.

Upvotes: 0

Views: 236

Answers (1)

Shloime Rosenblum
Shloime Rosenblum

Reputation: 1020

Set each DataGrid VerticalScrollBarVisibility="Hidden" and Height="Auto" and the ScrollViewer VerticalScrollBarVisibility="Auto" this will put only 1 ScrollBar for all DataGrid's.

If you don't want any ScrollBar at all you can use a ViewBox which will make everything smaller to fit on the page

Upvotes: 1

Related Questions