简体   繁体   English

多个网格上的垂直滚动条

[英]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). 我在XAML屏幕上放置了三个Windows Datagrids,每个网格都有不同的列和行(分别为6行,5行和4行)。 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. 如果我不将ScrollViewer.VerticalScrollBarVisibility =“ Visible”放在第一个网格上,则行6变得不在可见区域之内。

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. 谢谢。

Set each DataGrid VerticalScrollBarVisibility="Hidden" and Height="Auto" and the ScrollViewer VerticalScrollBarVisibility="Auto" this will put only 1 ScrollBar for all DataGrid's. 设置每个DataGrid VerticalScrollBarVisibility="Hidden"Height="Auto"以及ScrollViewer VerticalScrollBarVisibility="Auto"这将为所有DataGrid只放置1个ScrollBar。

If you don't want any ScrollBar at all you can use a ViewBox which will make everything smaller to fit on the page 如果您根本不想要任何ScrollBar,则可以使用ViewBox ,它将使所有内容变小以适合页面

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM