它不显示滚动条
本文关键字:滚动条 显示 | 更新日期: 2023-09-27 18:04:26
在这段代码中,我想要放置滚动条,所以我这样做了,但它不显示滚动条。
<ScrollViewer VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible">
<Grid Width="387" Height="186" Background="LightBlue" >
<TextBox Height="110" HorizontalAlignment="Left" TextWrapping="Wrap" Margin="6,6,0,0" Name="textBox1" VerticalAlignment="Top" Width="375" />
<TextBox Height="110" HorizontalAlignment="Left" TextWrapping="Wrap" Margin="6,122,0,0" Name="textBox2" VerticalAlignment="Top" Width="375" Grid.RowSpan="2" />
</Grid>
</ScrollViewer>
在您的示例中,Grid with LightBlue
color是容器控件,并有2个子textbox。您已经限制了该网格的Height
和Width
,这需要ScrollBar
来查看子控件(这里是文本框)。所以你需要保持你的ScrollBar
在父Grid
(浅蓝色网格)。请更改下面的XAML
,以启用水平和垂直ScrollBars
<Grid Width="387"
Height="186"
Background="LightBlue">
<ScrollViewer VerticalScrollBarVisibility="Visible"
HorizontalScrollBarVisibility="Visible">
<Grid>
<TextBox Height="110"
HorizontalAlignment="Left"
TextWrapping="Wrap"
Margin="6,6,0,0"
Name="textBox1"
VerticalAlignment="Top"
Width="375" />
<TextBox Height="110"
HorizontalAlignment="Left"
TextWrapping="Wrap"
Margin="6,122,0,0"
Name="textBox2"
VerticalAlignment="Top"
Width="375"
Grid.RowSpan="2" />
</Grid>
</ScrollViewer>
</Grid>