2013-08-23 53 views
1

我有一個列表框,裏面有大約150個項目。問題是它沒有采取任何事件。其他列表框有少於90個項目,他們工作正常。對於Windows Phone 8的列表框中的項目是否有任何限制?

是否有任何限制或防止事件handeling?

<ScrollViewer HorizontalAlignment="Left" Height="170" Margin="0,421,0,0" VerticalAlignment="Top" Width="480" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled"> 
         <ListBox Name="thirdList" Tap="firstList_SelectionChanged_1" Height="170" ScrollViewer.VerticalScrollBarVisibility="Disabled" > 

          <toolkit:GestureService.GestureListener> 
           <toolkit:GestureListener DragCompleted="GestureListener_DragCompleted"></toolkit:GestureListener> 
          </toolkit:GestureService.GestureListener> 

          <ListBox.ItemsPanel> 
           <ItemsPanelTemplate> 
            <StackPanel Orientation="Horizontal" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Disabled" /> 
           </ItemsPanelTemplate> 
          </ListBox.ItemsPanel> 
          <ListBox.ItemContainerStyle> 
           <Style TargetType="ListBoxItem"> 
            <Setter Property="Padding" Value="0 0 0 0 " /> 
           </Style> 
          </ListBox.ItemContainerStyle> 

          <ListBox.ItemTemplate> 
           <DataTemplate> 
            <StackPanel Orientation="Vertical" Height="170" Width="150" Background="Transparent"> 
             <!--Replace rectangle with image--> 
             <Image Source="{Binding image}" Stretch="UniformToFill" Margin="0,20" HorizontalAlignment="Left" VerticalAlignment="Bottom" Height="140" Width="119"></Image> 
             <Grid Margin="0,-335,0,0" HorizontalAlignment="Center" Background="Transparent" Height="30"> 
              <TextBlock TextAlignment="Center" Text="{Binding brandName}" HorizontalAlignment="Center" FontSize="15" TextWrapping="NoWrap" Foreground="#FFAA1F17" /> 
             </Grid> 
             <StackPanel Width="165" Margin="0,-65,0,0" Background="Transparent"> 
              <Grid HorizontalAlignment="Stretch" Height="55" Background="#FF9B9A9A"> 
               <StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center" Background="Transparent"> 
                <TextBlock TextAlignment="Center" Text="{Binding productName}" TextWrapping="Wrap" HorizontalAlignment="Center" Foreground="White" FontSize="15" /> 
                <TextBlock TextAlignment="Center" Text="{Binding price}" TextWrapping="Wrap" HorizontalAlignment="Center" Foreground="#99FFFFFF" FontSize="15" /> 
               </StackPanel> 
              </Grid> 
             </StackPanel> 
            </StackPanel> 
           </DataTemplate> 
          </ListBox.ItemTemplate> 
         </ListBox> 
        </ScrollViewer> 
+0

我不明白你的代碼的問題,但我用了超過500個項目的列表框。 –

+0

我試圖減少項目少於100,它的工作。 – vjamit

回答

1

vjamit請考慮使用LongListSelector爲Windows Phone 8個的應用程序,而不是舊的列表框。

我測試了超過5K項目的LLS,並且它的加載和播放效果都很好。

此外,根本不需要在ScrollViewer中包裝LLS。檢查下面的例子:

<phone:PhoneApplicationPage.Resources> 
    <DataTemplate x:Key="LLSTemplate"> 
     <Grid Tap="firstList_SelectionChanged_1"> 
      <toolkit:GestureService.GestureListener> 
       <toolkit:GestureListener DragCompleted="GestureListener_DragCompleted"></toolkit:GestureListener> 
      </toolkit:GestureService.GestureListener> 

      <StackPanel Orientation="Vertical" Height="170" Width="150" Background="Transparent"> 
       <!--Replace rectangle with image--> 
       <Image Source="{Binding image}" Stretch="UniformToFill" Margin="0,20" HorizontalAlignment="Left" VerticalAlignment="Bottom" Height="140" Width="119"></Image> 
       <Grid Margin="0,-335,0,0" HorizontalAlignment="Center" Background="Transparent" Height="30"> 
        <TextBlock TextAlignment="Center" Text="{Binding brandName}" HorizontalAlignment="Center" FontSize="15" TextWrapping="NoWrap" Foreground="#FFAA1F17" /> 
       </Grid> 
       <StackPanel Width="165" Margin="0,-65,0,0" Background="Transparent"> 
        <Grid HorizontalAlignment="Stretch" Height="55" Background="#FF9B9A9A"> 
         <StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center" Background="Transparent"> 
          <TextBlock TextAlignment="Center" Text="{Binding productName}" TextWrapping="Wrap" HorizontalAlignment="Center" Foreground="White" FontSize="15" /> 
          <TextBlock TextAlignment="Center" Text="{Binding price}" TextWrapping="Wrap" HorizontalAlignment="Center" Foreground="#99FFFFFF" FontSize="15" /> 
         </StackPanel> 
        </Grid> 
       </StackPanel> 
      </StackPanel> 
     </Grid> 
    </DataTemplate> 
</phone:PhoneApplicationPage.Resources> 


<!--ContentPanel - place additional content here--> 
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> 
     <phone:LongListSelector x:Name="thirdList" Height="170" ItemTemplate="{StaticResource LLSTemplate}"/> 
    </Grid> 

讓我知道如果以上的作品。

EDITED

嘗試應用在ScrollViewer中的以下變化:HorizontalScrollBarVisibility="Disabled"。經過500+測試,效果很好。看起來像一個「bug」。

+0

事情是,我需要水平滾動列表。據我所知和搜索,它不可能與LongListSelector。我可能請讓我知道。 – vjamit

+0

請檢查我做的編輯..它應該工作 - 它爲我做! –

+0

試圖..仍然沒有工作..它的工作原理是這樣的:當頁面加載顯示5項和輕敲事件的作品,然後更多的數據加載。一旦所有數據都被填充,Tap事件處理程序也不會被調用,也不會被GestureListener調用。可能與更新列表框有關。 – vjamit

相關問題