【问题标题】:How to manually scroll using ItemsRepeater如何使用 ItemsRepeater 手动滚动
【发布时间】:2019-11-14 14:58:43
【问题描述】:

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

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

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);

什么都没有发生。 为什么,谢谢。

【问题讨论】:

  • 您应用的目标最低版本是多少?
  • 你已经禁用 ScrollViewer HorizontalScrollMode,为什么用 horizontalOffset 调用 ChangeView?
  • 因为我将HorizontalScrollMode的值设置为Disable,所以可以防止鼠标滚轮。并使用ChangeView手动改变ScrollViewer的水平偏移量。
  • 作为 Pieter Nijs 的博客,blog.pieeatingninjas.be/2016/01/17/…。他还将ScrollMode的值设置为Disable,并使用ChangeView

标签: xaml uwp uwp-xaml


【解决方案1】:

如何使用 ItemsRepeater 手动滚动

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

更新

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

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多