我是Windows手机开发的新手,我需要水平滚动列出水平方式的图像。我尝试使用以下代码
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<GridView Name="display" ItemsSource="{Binding}" Foreground="#FFE6D52E">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsWrapGrid Orientation="Horizontal" MaximumRowsOrColumns="3"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="10">
<Image Source="{Binding Image}" Width="300" Height="300"/>
</StackPanel>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
</Grid>
但我需要将其显示如下
请指导我实现预期
提前致谢
答案 0 :(得分:2)
首先,将Orientation
从Horizontal
从Horizontal
更改为Vertical
。
第二步,启用ScrollViewer.VerticalScrollMode
。
<GridView Name="display"
VerticalAlignment="Top"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
ScrollViewer.HorizontalScrollMode="Enabled"
ScrollViewer.VerticalScrollMode="Disabled"
Foreground="#FFE6D52E">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsWrapGrid Orientation="Vertical"
MaximumRowsOrColumns="3"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.ItemTemplate>
<DataTemplate>
<Grid Margin="10">
<Image Source="{Binding }"
HorizontalAlignment="Center"
Stretch="Uniform"
Width="30"
Height="30"/>
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>