在搜索有关ScrollView未显示的帖子后,我找不到一个与我相似的例子。
请参阅下面的代码,我的ScrollView可见,但不可滚动。我想知道我需要改变哪一部分才能使其发挥作用?
<Page x:Class="Apps"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
Title="Apps"
VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Width="auto" Height="auto">
<ScrollViewer>
<StackPanel>
<Label Content="All applications stored on desktop computer" Height="28" Name="Label2" FontSize="16" FontWeight="Bold" HorizontalContentAlignment="Center" Margin="5" />
<Grid Margin ="10" HorizontalAlignment="Left" Name="gridApps" VerticalAlignment="Top" Width="auto">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"/>
<ColumnDefinition Width="150" />
<ColumnDefinition Width="150" />
<ColumnDefinition Width="150" />
<ColumnDefinition Width="150" />
<ColumnDefinition Width="150" />
<ColumnDefinition Width="150" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
</Grid>
</StackPanel>
</ScrollViewer>
</Page>
答案 0 :(得分:3)
当ScrollViewer内容的宽度或高度大于其自身的宽度或高度时,您的滚动条将可滚动。试试这个,你会看到它:
<ScrollViewer Name="scrollViewer" Margin="10" Width="100" Height="224" HorizontalScrollBarVisibility="Auto">
<StackPanel Name="stackPanel" Width="200" />
</ScrollViewer>
答案 1 :(得分:0)
万一你没试过这个(虽然,我不确定这会解决你的问题):
<ScrollViewer HorizontalScrollBarVisibility="Auto">
或
<ScrollViewer HorizontalScrollBarVisibility="Visible">
(第二个选项会快一点。)
答案 2 :(得分:0)
似乎在ScrollViewer上设置Height =“this here”
<ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="auto" verticalScrollBarVisibility="auto" Width="auto" Height="600">
<StackPanel x:Name="stackStores" Orientation="Vertical" >