【发布时间】: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="" 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);
什么都没有发生。 为什么,谢谢。
【问题讨论】:
-
您应用的目标最低版本是多少?
-
你已经禁用 ScrollViewer
HorizontalScrollMode,为什么用horizontalOffset调用 ChangeView? -
因为我将
HorizontalScrollMode的值设置为Disable,所以可以防止鼠标滚轮。并使用ChangeView手动改变ScrollViewer的水平偏移量。 -
作为 Pieter Nijs 的博客,blog.pieeatingninjas.be/2016/01/17/…。他还将
ScrollMode的值设置为Disable,并使用ChangeView。