2011-12-09 117 views
0

在搜索有关ScrollView不显示的帖子后,我找不到与我的类似的一个示例。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

哪里是你的网格内的内容?如果您在RowDefintion上放置固定高度,会发生什么情况? –

回答

0

好像设置身高=“一个在这里值”在ScrollViewer中工作

<ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="auto" verticalScrollBarVisibility="auto" Width="auto" Height="600"> 

    <StackPanel x:Name="stackStores" Orientation="Vertical" > 
3

你的滚动条会滚动的ScrollViewer时内容的宽度或高度会大于自身的宽度或高度。试试这个,你会看到它:

<ScrollViewer Name="scrollViewer" Margin="10" Width="100" Height="224" HorizontalScrollBarVisibility="Auto"> 
    <StackPanel Name="stackPanel" Width="200" /> 
</ScrollViewer> 
+0

是的,我试图把高度放在StackPanel上,它显示。然而,我正在动态填充我的网格,因此我希望我的StackPanel中的Height可以基于我的网格自动生成。任何想法如何将其设置为auto并同时允许ScrollViewer工作? –

+0

嗯......奇怪的东西...我已经'把'一个标签放入您的网格: '

+0

尝试做同样的...)我认为可以有问题与填充你的网格) – Anthony

0

万一你没有尝试过这一点(虽然我不知道这能解决你的问题):

<ScrollViewer HorizontalScrollBarVisibility="Auto"> 

<ScrollViewer HorizontalScrollBarVisibility="Visible"> 

(第二个选项会快一点)。