列表视图地铁应用程序中的垂直滚动

Vertical scroll in list view metro app

我有一个列表视图,我希望它垂直滚动。

我有以下代码。

<Grid Grid.Row="0">
                    <StackPanel Orientation="Vertical" VerticalAlignment="Top" Width="300" Margin="4,-27,0,0" HorizontalAlignment="Left">
                        <TextBlock x:Name="lbProbability" Text="Probability" Style="{StaticResource ContentTitleTextBlockStyle1}"/>
                        <StackPanel Orientation="Horizontal" Background="#FF362B61" Width="300"  Height="55" Margin="0,10,0,0" HorizontalAlignment="Left">
                            <AppBarButton Margin="0,-8,0,-10" Width="50" Icon="Favorite" IsCompact="True"/>
                            <!--<AppBarButton x:Name="btnAddActivity1" Margin="0,-10,0,-10" IsCompact="True" Icon="Bullets" Margin="-50,-20,0,-20" Width="70" Height="70"/>-->
                            <!--<Image Source="Assets/add.png" Width="30" Height="30" Margin="10,0,0,0" />-->
                            <TextBlock Text="Obectives" Style="{StaticResource ContentTitleTextBlockStyle1}"  Margin="10,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                        </StackPanel>
                        <StackPanel Width="300" Height="122">
                            <ListView x:Name="lsvObjectives" IsItemClickEnabled="True" SelectionMode="Multiple" CanDragItems="True" AllowDrop="True" ItemsSource="{Binding Source={StaticResource cvs1}}" DragItemsStarting="lsvObjectives_DragItemsStarting" ScrollViewer.VerticalScrollBarVisibility="Visible"  >
                                <ListView.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <WrapGrid Orientation="Horizontal" HorizontalChildrenAlignment="left"/>
                                    </ItemsPanelTemplate>
                                </ListView.ItemsPanel>
                                <ListView.ItemContainerStyle>
                                    <Style TargetType="ListViewItem">
                                        <Setter Property="Padding" Value="0"/>
                                        <Setter Property="Margin" Value="-7"/>
                                    </Style>
                                </ListView.ItemContainerStyle>
                                <ListView.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Vertical" Margin="0,0,0,0" HorizontalAlignment="Center" >
                                            <StackPanel Orientation="Horizontal" Width="310" Height="33" Background="#FFE9D5F0" HorizontalAlignment="Left">
                                                <StackPanel Width="210" VerticalAlignment="Center" Margin="10,5,0,0">
                                                    <TextBlock Text="{Binding Name}" Style="{StaticResource ContentTextBlockStyle}" Foreground="Black" VerticalAlignment="Center" HorizontalAlignment="Left"/>
                                                </StackPanel>
                                                <StackPanel Width="60" Margin="15,0,0,0" VerticalAlignment="Center">
                                                    <TextBlock Text="{Binding Week}" Style="{StaticResource ContentTextBlockStyle}" Foreground="#FFAE1654" />
                                                </StackPanel>
                                            </StackPanel>
                                        </StackPanel>
                                    </DataTemplate>
                                </ListView.ItemTemplate>
                            </ListView>
                        </StackPanel>
                    </StackPanel>
                </Grid> 

我已经绑定了我的 cs 代码中的值。我无法垂直滚动滚动条出现但它不起作用。我找不到我的错误,有人可以帮我解决这个问题吗?

感谢任何形式的帮助。

这是因为 StackPanel 中的 ListView 控件,删除 StackPanel 应该可以,这是编辑后的代码:

<Grid Grid.Row="0">
                    <StackPanel Orientation="Vertical" VerticalAlignment="Top" Width="300" Margin="4,-27,0,0" HorizontalAlignment="Left">
                        <TextBlock x:Name="lbProbability" Text="Probability" Style="{StaticResource ContentTitleTextBlockStyle1}"/>
                        <StackPanel Orientation="Horizontal" Background="#FF362B61" Width="300"  Height="55" Margin="0,10,0,0" HorizontalAlignment="Left">
                            <AppBarButton Margin="0,-8,0,-10" Width="50" Icon="Favorite" IsCompact="True"/>
                            <!--<AppBarButton x:Name="btnAddActivity1" Margin="0,-10,0,-10" IsCompact="True" Icon="Bullets" Margin="-50,-20,0,-20" Width="70" Height="70"/>-->
                            <!--<Image Source="Assets/add.png" Width="30" Height="30" Margin="10,0,0,0" />-->
                            <TextBlock Text="Obectives" Style="{StaticResource ContentTitleTextBlockStyle1}"  Margin="10,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                        </StackPanel>

                            <ListView Width="300" Height="122" x:Name="lsvObjectives" IsItemClickEnabled="True" SelectionMode="Multiple" CanDragItems="True" AllowDrop="True" ItemsSource="{Binding Source={StaticResource cvs1}}" DragItemsStarting="lsvObjectives_DragItemsStarting" ScrollViewer.VerticalScrollBarVisibility="Visible"  >
                                <ListView.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <WrapGrid Orientation="Horizontal" HorizontalChildrenAlignment="left"/>
                                    </ItemsPanelTemplate>
                                </ListView.ItemsPanel>
                                <ListView.ItemContainerStyle>
                                    <Style TargetType="ListViewItem">
                                        <Setter Property="Padding" Value="0"/>
                                        <Setter Property="Margin" Value="-7"/>
                                    </Style>
                                </ListView.ItemContainerStyle>
                                <ListView.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Vertical" Margin="0,0,0,0" HorizontalAlignment="Center" >
                                            <StackPanel Orientation="Horizontal" Width="310" Height="33" Background="#FFE9D5F0" HorizontalAlignment="Left">
                                                <StackPanel Width="210" VerticalAlignment="Center" Margin="10,5,0,0">
                                                    <TextBlock Text="{Binding Name}" Style="{StaticResource ContentTextBlockStyle}" Foreground="Black" VerticalAlignment="Center" HorizontalAlignment="Left"/>
                                                </StackPanel>
                                                <StackPanel Width="60" Margin="15,0,0,0" VerticalAlignment="Center">
                                                    <TextBlock Text="{Binding Week}" Style="{StaticResource ContentTextBlockStyle}" Foreground="#FFAE1654" />
                                                </StackPanel>
                                            </StackPanel>
                                        </StackPanel>
                                    </DataTemplate>
                                </ListView.ItemTemplate>
                            </ListView>

                    </StackPanel>
                </Grid>