2011-07-03 163 views
2

嗨我想创建一个循环列表框,以便最后一个项目的下一个项目是第一个项目,反之亦然 - 创建一个没有顶部或底部的列表框。创建一个循环列表框

我知道WP7工具包中有一个LoopingSelector,但它并不完全符合我的要求,因为它会淡入/淡出周边物品,并且您有一个始终位于中间的“选定”项目。

我看着LinkedList的集合,但它似乎并不支持循环:“只有LinkedList(Of T)类不支持链接,分裂,周期,或其他特征,可以给在列表不一致的状态。“

有谁知道我正在寻找的解决方案还是需要开发当前Listbox和Toolkit的LoopingSelector的混合?

很多thanx!

回答

1

我最近遇到同样的问题!我使用blend 4来处理这个问题,使得我的列表在特定时间重置到某个位置,同时在原始列表的前面和后面添加一个列表副本。

例如:我的名单是:1-2-3-4-5-6, 我会让它1-2-3-4-5-6-1-2-3-4-5-6 -1-2-3-4-5-6 ,并且它每20秒重置到原始位置。例如:如果用户在项目4上,它会将位置重置为项目4,但是在中间列表中。

我现在有我的问题问在这里你可以,如果任何帮助检查出: horizontal listbox that could be infinite circle scrolling

+0

您好ng_ducnghia,所以如果我理解正确,你有一个列表,并在该列表中复制原始列表两次,以便每个项目有3个它的实例? 重置位置是否使用ScrollIntoView方法? – n00b

+0

嗨n00b,我最近解决了这个问题。我在滚动查看器里面有我的列表框(确保你禁用列表框滚动),并且我使用scrollviewer的操作完成事件,这意味着当你滚动到结尾时,它会采取行动。然后,我通过使用scrollToHorizo​​ntalOffset(或scrolltoVerticalOffset)将它转到第一项。 –

0

使用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在两个单向循环。