gpt4 book ai didi

gridview - 如何在 Windows Phone 8.1 WinRT 中启用 GridView 的左右滚动?

转载 作者:行者123 更新时间:2023-12-01 11:38:38 25 4
gpt4 key购买 nike

我正在尝试将 GridView 的方向从默认的上下更改为左右。只是即使从后面的代码调用 ScrollIntoView 工作得很好,我也无法让手动滚动起作用。以下是我的测试项目的详细信息。

1) 文件 >> 新建项目 >> Hub 应用程序 (Windows Phone)

2) HubPage.xaml(删除了 Hub 控件并仅替换为 GridView)

    <Grid x:Name="LayoutRoot" DataContext="{Binding Groups[5]}">
<GridView x:Name="GridView1" Margin="0,9.5,0,0"
ItemsSource="{Binding Items}"
SelectionMode="None"
IsItemClickEnabled="True"
ItemClick="ItemView_ItemClick"
ScrollViewer.VerticalScrollBarVisibility="Visible"
ScrollViewer.HorizontalScrollBarVisibility="Visible">

<GridView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsWrapGrid Orientation="Vertical"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollBarVisibility="Visible"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>

<GridView.ItemTemplate>
<DataTemplate>
<Grid Margin="0,0,9.5,9.5"
Background="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}">
<Image Source="{Binding ImagePath}"
Stretch="UniformToFill"
AutomationProperties.Name="{Binding Title}"
Height="200"
Width="200"/>
<TextBlock Text="{Binding Title}"
VerticalAlignment="Bottom"
Margin="9.5,0,0,6.5"
Style="{ThemeResource BaseTextBlockStyle}"/>
</Grid>
</DataTemplate>
</GridView.ItemTemplate>

</GridView>
</Grid>

3) HubPage.xaml.vb(仅在此点击处理程序中更改)

Private Sub ItemView_ItemClick(sender As Object, e As ItemClickEventArgs)
GridView1.ScrollIntoView(GridView1.Items.Last)
End Sub

我在这里错过了什么?

最佳答案

GridView 需要启用它。所以,在GridView中,还需要设置Horizo​​ntalScrollMode属性。

<GridView x:Name="GridView1" Margin="0,9.5,0,0"
ItemsSource="{Binding Items}"
SelectionMode="None"
IsItemClickEnabled="True"
ItemClick="ItemView_ItemClick"
ScrollViewer.VerticalScrollBarVisibility="Visible"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.HorizontalScrollMode="Auto">

....

</GridView>

关于gridview - 如何在 Windows Phone 8.1 WinRT 中启用 GridView 的左右滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24553597/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com