为什么我的网格不垂直滚动

时间:2014-11-19 16:43:13

标签: c# wpf xaml windows-phone-8

即使我将包裹网格中的方向更改为垂直或水平,我的网格也不会垂直滚动。但是在横向上我的项目是垂直排列的,我确实让滚动条滚动但是当我使用滚动条时它不能垂直工作。

 <Grid Grid.Row="2" VerticalAlignment="Center" Margin="120,0,0,0">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <TextBlock FontSize="26" Text="You are assigned to the following wards, please select one to continue:"/>
        <GridView Name="WardGridView" ItemsSource="{Binding 
        Source={StaticResource WardGridViewCollectionViewSource}}" 
              SelectionMode="None" 
              IsItemClickEnabled="True" ScrollViewer.VerticalScrollBarVisibility="Auto"
              ItemClick="WardGridView_ItemClick" Grid.Row="1" >
            <GridView.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapGrid Margin="0,0,0,10" Orientation="Horizontal"/>
                </ItemsPanelTemplate>
            </GridView.ItemsPanel>
            <GridView.ItemTemplate>
                <DataTemplate>
                    <Grid Width="1000" Height="500" Background="#DBDBDB">
                        <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Black" FontFamily="Segoe UI" Text="{Binding message}" FontSize="20" />
                    </Grid>
                </DataTemplate>
            </GridView.ItemTemplate>
        </GridView>
    </Grid>

我需要在代码中更改哪些内容才能让我的项目垂直滚动?

1 个答案:

答案 0 :(得分:3)

将RowDefinition更改为:

  <!-- Row where the GridView is shown -->
  <RowDefinition Height="*" />