简体   繁体   中英

Why does my grid not scroll vertically

My grid does not scroll vertically even when I change the orientation in my wrapgrid to vertical or horizontal. However in horizontal my items are arranged vertically and I do get the scroll bar to scroll but when I use the scroll bar it does not work vertically.

 <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>

what do I need to change in my code to allow my items to scroll vertically?

Change the RowDefinition to this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM