在这段代码中,我想把滚动条放在那里,因为我做了那个,但它没有显示滚动。
<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>
答案 0 :(得分:0)
在您的示例中,具有LightBlue
颜色的网格是容器控件,并且具有2个子文本框。您已限制此网格的Height
和Width
,该网格需要ScrollBar
才能查看子控件(此处为文本框)。因此,您需要将ScrollBar
保留在父Grid
内(LightBlue颜色网格)。请更改您的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>