2011-12-22 3 views
1

ループのセレクタがリストの最後に来たときにループしないようにする方法はありますか?リストには1,2,3,4 ... 10の10個のアイテムがあるとしましょう。一度スクロールした後にリストの最後に到達すると、つまり10になると、ループすることはできません。ルーピングセレクタの流れを示す。それは可能..ですWP7ループセレクタのセレクタリストの最後にループを停止します

public void DisplayCatalog(string[] ServiceDisplayName, string[] WheelDisplayName, BitmapImage[] ServiceIcons, WidgetBean[] ServiceBeanList, WidgetBean[] WheelBeanList) 
    { 
     updateUI(); 
     DisplayNames.Clear(); 
     int idIndex = 0; 

       for (int j = 0; j < WheelDisplayName.Length; j++) 
       { 
        string disp1 = WheelDisplayName[j]; 
        if (!Utils.isNullString(disp1)) 
        { 
         DisplayNames.Add(new ItemList() { WidgetName = disp1, ID = (idIndex + 1) }); 
         idIndex += 1; 
        } 
       } 
this.selectorLeft.DataSource = new ListLoopingDataSource<ItemList>() { Items = DisplayNames, selectedItem = DisplayNames[Index] }; 

対応するXAML:?私は一年以来、この問題の解決策を見つけるのに苦労した

<loop:LoopingSelector 
      x:Name="selectorLeft" VerticalAlignment="Center" ItemSize="200,68" Height="63" 
           d:LayoutOverrides="Height" Width="450"> 
      <loop:LoopingSelector.ItemTemplate> 
       <DataTemplate> 
        <StackPanel Background="#FF48BA1C" Height="75"> 
         <TextBlock Margin="2,12,2,2" Width="Auto" TextTrimming="WordEllipsis" TextAlignment="Center" x:Name="scrollingTextBlock" 
            Text="{Binding WidgetName}" FontSize="26" Foreground="White" VerticalAlignment="Bottom" HorizontalAlignment="Stretch"/> 
        </StackPanel> 
       </DataTemplate> 
      </loop:LoopingSelector.ItemTemplate> 
     </loop:LoopingSelector> 

答えて

1

(水平ループセレクタを使用しています)。今日私はthisを見つけました。私はちょうど1つの変更を加えなければならなかった。それは

this.selectorLeft.DataSource = new ListLoopingDataSource<ItemList>(WheelDisplayName.Length+1) { Items = DisplayNames, selectedItem = DisplayNames[Index] }; 

ループセレクタループアイテムの合計数は、それが最後の項目の終わりにループ停止するいない場合WheelDisplayName + 1よりも大きい場合にのみ...です。

+0

リンクを更新することはできますか?これはまさに私が探しているものです!ありがとう! – Quincy

+0

完了!更新された回答を確認してください – Apoorva

0

ILoopingSelectorDataSourceを実装します。 GetPrevious/GetNextで、リストの先頭/末尾にnullを返します。

最新のツールキットをダウンロードし、GetNextの返品をコメントアウトしてください。サンプルが次の項目を表示しないので、ループしません。

abstract class DataSource : ILoopingSelectorDataSource 
{ 
    private DateTimeWrapper _selectedItem; 

    public object GetNext(object relativeTo) 
    { 
     DateTime? next = GetRelativeTo(((DateTimeWrapper)relativeTo).DateTime, 1); 
     return null;// next.HasValue ? new DateTimeWrapper(next.Value) : null; 
    } 

    public object GetPrevious(object relativeTo) 
    { 
     DateTime? next = GetRelativeTo(((DateTimeWrapper)relativeTo).DateTime, -1); 
     return next.HasValue ? new DateTimeWrapper(next.Value) : null; 
    } 
関連する問題