Windows Phone 8 的列表框中的项目有任何限制吗? [英] is there any limit for items in a listbox for windows phone 8?

查看:18
本文介绍了Windows Phone 8 的列表框中的项目有任何限制吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含大约 150 个项目的列表框.问题是它没有采取任何事件.其他列表框的项目少于 90 个,它们运行良好.

i have a listbox with around 150 items in it. the problem is that it is not taking any events. other listboxes have less than 90 items and they are working fine.

是否有任何限制或阻止事件处理的东西??

is there any limit or something which is preventing event 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>

推荐答案

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

vjamit please consider using LongListSelector for Windows Phone 8 applications and not the old ListBox.

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

I have tested LLS with more than 5k items and it loads and plays just fine.

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

Also there is no need at all to wrap LLS in a ScrollViewer. Check below example:

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

让我知道以上是否有效.

Let me know if the above works.

已编辑:

尝试在 ScrollViewer 上应用以下更改:Horizo​​ntalScrollBarVisibility="Disabled".用 500+ 测试,它有效.看起来像一个错误".

Try applying the following changes on the ScrollViewer: HorizontalScrollBarVisibility="Disabled". Tested with 500+ and it works. Seems like a "bug".

这篇关于Windows Phone 8 的列表框中的项目有任何限制吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆