xaml - 如何使用 ItemsRepeater 手动滚动
问题描述
我正在使用ItemsRepeater
. 并使用 aScrollViewer
向左/向右滚动。
出于某种原因,我必须禁用ScrollViewer
' HorizontalScrollMode
,并将 Left/Right 添加Button
到手动滚动中。
xml是
<Grid>
<muxc:ItemsRepeaterScrollHost Margin="12" Loaded="ItemsRepeaterScrollHost_Loaded">
<ScrollViewer
x:Name="sss"
VerticalScrollBarVisibility="Hidden"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollMode="Disabled"
HorizontalScrollMode="Disabled">
<muxc:ItemsRepeater
x:Name="HorizontalRepeater"
ItemsSource="{x:Bind product}"
ItemTemplate="{StaticResource HorizontalTemplate}">
<muxc:ItemsRepeater.Layout>
<muxc:StackLayout Orientation="Horizontal" Spacing="12"/>
</muxc:ItemsRepeater.Layout>
</muxc:ItemsRepeater>
</ScrollViewer>
</muxc:ItemsRepeaterScrollHost>
<Button
x:Name="ButtonLeft"
Tapped="ButtonLeft_Tapped">
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="" FontSize="18" />
</Button>
<Button x:Name="ButtonRight"
Tapped="ButtonRight_Tapped">
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="" FontSize="18" />
</Button>
</Grid>
然后我用
sss.ChangeView(step, null, null);
没发生什么事。为什么,谢谢。
解决方案
如何使用 ItemsRepeater 手动滚动
对于我的测试,ChangeView
不适用于ItemsRepeater
,请尝试将其替换为ScrollToHorizontalOffset
orScrollToVerticalOffset
方法。
更新
将操作系统更新到最新版本(1909)后ChangeView
运行良好,这可能是以前版本的问题。
推荐阅读
- spin - Mac上的jspin,点击验证时,结果是error=13权限被拒绝
- javascript - 在javascript中使用多个条件进行过滤
- bash - shell脚本中的多部分电子邮件
- mongodb - 如何删除对象数组[MongoDB]中对象的[嵌套]内部的对象?
- python - 如何在不使用 python 循环的情况下将元素插入 3d numpy 数组中的特定索引?
- google-tag-manager - GTM 从数据层创建自定义数组
- flutter - Flutter:从 FloatingActionButton 重新构建小部件
- python - Numpy recarray函数抛出TypeError:无法使用灵活类型执行reduce
- python - 在 pandas read_csv 文件中打开 .csv 文件时,在一列中显示所有列
- python - 如何更改 python 代码以抓取带有重音字符的文本?