在模拟器模式下测试,即使我有100条记录显示,GridView也不会垂直滚动,它显示一个垂直条但不能用于滚动。我需要做些什么来使其垂直或水平滚动?
对此问题表示感谢。感谢
<GridView x:Name="CustomersGridView" Grid.Row="1" Margin="37,174,73,89" Foreground="White" SelectionMode="Single" IsSwipeEnabled="True" IsItemClickEnabled="True" ItemsSource="{Binding Mode=OneWay, Source={StaticResource CustomersViewSource}}" ItemTemplate="{StaticResource CustomerTemplate}" ItemClick="CustomersGridView_ItemClick" // Horizontal or vertical here: ScrollViewer.HorizontalScrollBarVisibility="Auto" SelectionChanged="CustomersGridView_SelectionChanged"> <GridView.ItemsPanel> <ItemsPanelTemplate> <WrapGrid Orientation="Horizontal" /> </ItemsPanelTemplate> </GridView.ItemsPanel> </GridView>
答案 0 :(得分:2)
将控件包裹在ScrollViewer
中例如:
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowTitle="ScrollViewer Sample">
<ScrollViewer HorizontalScrollBarVisibility="Auto">
<StackPanel VerticalAlignment="Top" HorizontalAlignment="Left">
<TextBlock TextWrapping="Wrap" Margin="0,0,0,20">Scrolling is enabled when it is necessary.
Resize the window, making it larger and smaller.</TextBlock>
<Rectangle Fill="Red" Width="500" Height="500"></Rectangle>
</StackPanel>
</ScrollViewer>
</Page>