问题
I'm using ItemsRepeater. And using a ScrollViewer to scroll left/right.
For some reason, I have to disable ScrollViewer' HorizontalScrollMode, and add Left/Right Button to manual scroll.
The xaml is
<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>
Then I use
sss.ChangeView(step, null, null);
Nothing happens. Why, thx.
回答1:
How to manually scroll using ItemsRepeater
For my testing, ChangeView can't works for ItemsRepeater, Please try replace it with ScrollToHorizontalOffset or ScrollToVerticalOffset method.
Update
After update OS to latest version (1909) ChangeView works well, It may be a issue within previous version.
来源:https://stackoverflow.com/questions/58815861/how-to-manually-scroll-using-itemsrepeater