首页 > 解决方案 > 如何使用 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="&#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);

没发生什么事。为什么,谢谢。

标签: xamluwpuwp-xaml

解决方案


如何使用 ItemsRepeater 手动滚动

对于我的测试,ChangeView不适用于ItemsRepeater,请尝试将其替换为ScrollToHorizontalOffsetorScrollToVerticalOffset方法。

更新

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


推荐阅读