1

我有一个包含大约 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>
4

1 回答 1

1

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

我已经用超过 5k 个项目测试了 LLS,它加载和播放都很好。

此外,根本不需要将 LLS 包装在 ScrollViewer 中。检查以下示例:

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

让我知道以上是否有效。

编辑

尝试在 ScrollViewer 上应用以下更改HorizontalScrollBarVisibility="Disabled":用 500+ 测试,它的工作原理。似乎是一个“错误”。

于 2013-08-23T18:07:55.767 回答