CSharp - 可以滚动网格

  显示原文与译文双语对照的内容
0 0

如果我已经有了一个 overflow:scroll,那么我就很感激在CSS中使用一个类似于的网格,所以在CSS中我需要类似的东西,所以如果有人可以帮助我。


<Grid Margin="12,49,0,54" Name="state_settings" Width="430" Visibility="Hidden" MaxHeight="200" Height="200" HorizontalAlignment="Left" VerticalAlignment="Top">
 <ScrollViewer VerticalScrollBarVisibility="Auto" CanContentScroll="True">
 <Grid Height="69" HorizontalAlignment="Left" Margin="13,10,0,0" Name="state_comp" VerticalAlignment="Top" Width="406">
 <Label Content="Gesture" Height="28" HorizontalAlignment="Left" Margin="6,6,0,0" Name="label1" VerticalAlignment="Top" Width="103" FontWeight="Bold"/>
 <ComboBox Height="23" HorizontalAlignment="Left" Margin="6,31,0,0" Name="comboBox1" VerticalAlignment="Top" Width="103"/>
 <TextBox Height="23" HorizontalAlignment="Left" Margin="167,31,0,0" Name="textBox1" VerticalAlignment="Top" Width="27"/>
 <Label Content="Min Duration" Height="28" HorizontalAlignment="Left" Margin="135,6,0,0" Name="label2" VerticalAlignment="Top" Width="89" FontWeight="Bold"/>
 <TextBox Height="23" HorizontalAlignment="Left" Margin="258,31,0,0" Name="textBox2" VerticalAlignment="Top" Width="27"/>
 <TextBox Height="23" HorizontalAlignment="Left" Margin="346,31,0,0" Name="textBox3" VerticalAlignment="Top" Width="36"/>
 <Label Content="Max Duration" Height="28" HorizontalAlignment="Left" Margin="230,6,0,0" Name="label3" VerticalAlignment="Top" Width="89" FontWeight="Bold"/>
 <Label Content="Transition" Height="28" HorizontalAlignment="Left" Margin="327,6,0,0" Name="label4" VerticalAlignment="Top" Width="71" FontWeight="Bold"/>
 </Grid>
 </ScrollViewer>
</Grid>

时间: 原作者:

0 0

我必须改变一些东西,使它更容易处理你的代码。 例如,我必须删除 Visibility="Hidden",这对于你的示例来说很傻笑。 我还添加了 Background 颜色,以便可以看到 Grid的边界。 我移动 ScrollViewer 成为最外层的元素并移除不必要的CanContentScroll 属性和一些 Height 设置,但是除了这个之外,你几乎拥有它。 尝试这个:


<ScrollViewer VerticalScrollBarVisibility="Auto">
 <Grid Name="state_settings" Width="430" MaxHeight="200" Background="LightBlue" HorizontalAlignment="Left" VerticalAlignment="Top">
 <Grid Height="69" HorizontalAlignment="Left" Margin="13,10,0,0" Name="state_comp" VerticalAlignment="Top" Width="406">
 <Label Content="Gesture" Height="28" HorizontalAlignment="Left" Margin="6,6,0,0" Name="label1" VerticalAlignment="Top" Width="103" FontWeight="Bold"/>
 <ComboBox Height="23" HorizontalAlignment="Left" Margin="6,31,0,0" Name="comboBox1" VerticalAlignment="Top" Width="103"/>
 <TextBox Height="23" HorizontalAlignment="Left" Margin="167,31,0,0" Name="textBox1" VerticalAlignment="Top" Width="27"/>
 <Label Content="Min Duration" Height="28" HorizontalAlignment="Left" Margin="135,6,0,0" Name="label2" VerticalAlignment="Top" Width="89" FontWeight="Bold"/>
 <TextBox Height="23" HorizontalAlignment="Left" Margin="258,31,0,0" Name="textBox2" VerticalAlignment="Top" Width="27"/>
 <TextBox Height="23" HorizontalAlignment="Left" Margin="346,31,0,0" Name="textBox3" VerticalAlignment="Top" Width="36"/>
 <Label Content="Max Duration" Height="28" HorizontalAlignment="Left" Margin="230,6,0,0" Name="label3" VerticalAlignment="Top" Width="89" FontWeight="Bold"/>
 <Label Content="Transition" Height="28" HorizontalAlignment="Left" Margin="327,6,0,0" Name="label4" VerticalAlignment="Top" Width="71" FontWeight="Bold"/>
 </Grid>
 </Grid>
</ScrollViewer>

如果你需要减少 WindowHeight,或者添加更多项目以实际看到垂直 ScrollBar,那么你现在应该看到它在滚动,但是你可以看到。

你的用户界面有一个 ScrollBar:
enter image description here

原作者:
...