Windows Phone 8的列表框中的项目是否有限制?

时间:2013-08-23 07:14:05

标签: xaml windows-phone-8

我有一个包含大约150个项目的列表框。问题是它没有采取任何事件。其他列表框少于90项,它们工作正常。

是否有任何限制或某事阻止事件处理?

<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>

1 个答案:

答案 0 :(得分:1)

vjamit请考虑使用LongListSelector用于Windows Phone 8应用程序,而不是旧的ListBox。

我已经测试了超过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+,它的工作原理。看起来像是一个“虫子”。