简体   繁体   English

uwp固定位置网格

[英]uwp fixed position grid

There are three child grid under one parent grid. 一个父网格下有三个子网格。

<Grid>  
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>

        <Grid Grid.Row="0" Name="grid1"> </Grid>
        <Grid Grid.Row="1" Name="grid2"> </Grid>
        <Grid Grid.Row="2" Name="grid3"> </Grid>
</Grid>

if grid2 has more data then all three grids are scrolling. 如果grid2有更多数据,则所有三个网格都在滚动。 I want the Position of grid1 and grid3 should be fixed, only middle grid should scroll 我希望grid1和grid3的位置应该固定,只有中间网格应该滚动

If you can , please use fixed size value for grid1 and grid3 Rows Height 如果可以,请为grid1和grid3使用固定的大小值
You can use Scroll Viewer control 您可以使用滚动查看器控件

   <Grid>  
    <Grid.RowDefinitions>
        <RowDefinition Height="50"/>
        <RowDefinition Height="*"/>
        <RowDefinition Height="50"/>
    </Grid.RowDefinitions>

    <Grid Grid.Row="0" VerticalAlignment="Top" Name="grid1"> </Grid>
    <Grid Grid.Row="1" Name="grid2"> 
     <ScrollViewer VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible">
          //Content Here
     </ScrollViewer>
       </Grid>
    <Grid Grid.Row="2" VerticalAlignment="Bottom" Name="grid3"> </Grid>
   </Grid>
<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="auto"/>
        <RowDefinition Height="*"/>
        <RowDefinition Height="auto"/>
    </Grid.RowDefinitions>

    <Grid Grid.Row="0" Name="grid1" Margin="10">
        <TextBlock Text="Some Data"/>
    </Grid>
    <Grid Grid.Row="1" Name="grid2" Margin="10">
        <ScrollViewer VerticalScrollMode="Auto">
            <StackPanel>
                <TextBlock Text="Some Data "/>
                <TextBlock Text="Some Data "/>
                <TextBlock Text="Some Data "/>
                <TextBlock Text="Some Data "/>
                <TextBlock Text="Some Data "/>
                <TextBlock Text="Some Data "/>
                <TextBlock Text="Some Data "/>
                <TextBlock Text="Some Data "/>
                <TextBlock Text="Some Data "/>
                <TextBlock Text="Some Data "/>
                <TextBlock Text="Some Data "/>
                <TextBlock Text="Some Data "/>
                <TextBlock Text="Some Data "/>
                <TextBlock Text="Some Data "/>
                <TextBlock Text="Some Data "/>
                <TextBlock Text="Some Data "/>
                <TextBlock Text="Some Data "/>
                <TextBlock Text="Some Data "/>
            </StackPanel>                
        </ScrollViewer>
    </Grid>
    <Grid Grid.Row="2" Name="grid3" Margin="10">
        <TextBlock Text="Some Data"/>
    </Grid>
</Grid>

输出量

*You Need to set Horizontal/Vertical Scroll Mode to Auto/Enable *您需要将水平/垂直滚动模式设置为自动/启用

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

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