如何使用 ItemsRepeater 手动滚动 [英] How to manually scroll using ItemsRepeater

查看:29
本文介绍了如何使用 ItemsRepeater 手动滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 ItemsRepeater.并使用 ScrollViewer 向左/向右滚动.

I'm using ItemsRepeater. And using a ScrollViewer to scroll left/right.

出于某种原因,我必须禁用 ScrollViewer' Horizo​​ntalScrollMode,并将左/右 Button 添加到手动滚动.

For some reason, I have to disable ScrollViewer' HorizontalScrollMode, and add Left/Right Button to manual scroll.

xaml 是

<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="&#xE76B;" FontSize="18" />
                    </Button>

                    <Button x:Name="ButtonRight"
                        Tapped="ButtonRight_Tapped">
                        <FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xE76C;" FontSize="18" />
                    </Button>
                </Grid>

然后我用

sss.ChangeView(step, null, null);

什么都没发生.为什么,谢谢.

Nothing happens. Why, thx.

推荐答案

如何使用 ItemsRepeater 手动滚动

How to manually scroll using ItemsRepeater

对于我的测试,ChangeView 不能用于 ItemsRepeater,请尝试将其替换为 ScrollToHorizo​​ntalOffsetScrollToVerticalOffset 方法.

For my testing, ChangeView can't works for ItemsRepeater, Please try replace it with ScrollToHorizontalOffset or ScrollToVerticalOffset method.

更新

将操作系统更新到最新版本 (1909) 后 ChangeView 运行良好,可能是之前版本的问题.

After update OS to latest version (1909) ChangeView works well, It may be a issue within previous version.

这篇关于如何使用 ItemsRepeater 手动滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆