使用ScrollViewer中包含列表框,把ManipulationCompleted事件,并使用ScrolltoVerticalOffset(0)有它循环滚动。也许我的代码将有助于:
<ScrollViewer HorizontalScrollBarVisibility="Auto" Margin="-2,567,-1,0" x:Name="imagesScrollview"
Opacity="1" Grid.Row="1" RenderTransformOrigin="0.5,0.5"
ManipulationCompleted="imagesScrollview_ManipulationCompleted" Height="85" MouseLeftButtonDown="ScrollViewer_MouseLeftButtonDown">
<ScrollViewer.Background>
<ImageBrush ImageSource="/PhoneApp11;component/Images/top_friends_float.png" />
</ScrollViewer.Background>
<ListBox x:Name="listBox" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled" Width="Auto" Height="80" Background="{x:Null}">
<ListBox.ItemTemplate>
<DataTemplate>
和操纵事件:
private void imagesScrollview_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
{
ScrollViewer scrollviewer = sender as ScrollViewer;
if (scrollviewer.HorizontalOffset > (listBox.ActualWidth - 700))
scrollviewer.ScrollToHorizontalOffset(0);
else if (scrollviewer.HorizontalOffset < 100)
scrollviewer.ScrollToHorizontalOffset((listBox.ActualWidth - 487));
}
***请注意:我让我的ScrollViewer在两个单向循环。
您好ng_ducnghia,所以如果我理解正确,你有一个列表,并在该列表中复制原始列表两次,以便每个项目有3个它的实例? 重置位置是否使用ScrollIntoView方法? – n00b
嗨n00b,我最近解决了这个问题。我在滚动查看器里面有我的列表框(确保你禁用列表框滚动),并且我使用scrollviewer的操作完成事件,这意味着当你滚动到结尾时,它会采取行动。然后,我通过使用scrollToHorizontalOffset(或scrolltoVerticalOffset)将它转到第一项。 –