问题描述
我正在使用 ItemsRepeater
.并使用 ScrollViewer
向左/向右滚动.
I'm using ItemsRepeater
. And using a ScrollViewer
to scroll left/right.
出于某种原因,我必须禁用 ScrollViewer
' HorizontalScrollMode
,并将左/右 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="" 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);
什么都没发生.为什么,谢谢.
Nothing happens.Why, thx.
推荐答案
对于我的测试,ChangeView
不能用于 ItemsRepeater
,请尝试将其替换为 ScrollToHorizontalOffset
或 ScrollToVerticalOffset
方法.
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 手动滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!