滚动LongListSelector的奇怪行为 - WP8 [英] Strange behavior scrolling LongListSelector - WP8

查看:84
本文介绍了滚动LongListSelector的奇怪行为 - WP8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,我将用户的联系人保存在本地数据库中,然后将这些联系人绑定在LongListSelector中。

I have an app where I save the user's contacts in a local Database, then bind this contacts in a LongListSelector.

该应用程序有一个按钮,当点击时,更新本地数据库(使其
与devide相同
)。

The app has a button that,, when clicked, update the local database (make it identical to the devide).

当有变化时,LongListSelector在从搜索返回到列表(视图)后有一个奇怪的行为:当我快速滚动或滚动一段时间后,会出现一个空白区域列表的中间。然后我发现,显然,
列表正在削减一些项目...

When there is changes, the LongListSelector has a strange behavior after return from search to the list (view): when I scroll fast or after some time scrolling, a blank space appears in the middle of the list. Then I found out that, apparently, the list is cutting some items...

这种行为只有在我有一个很长的列表,比如50个或更多项..

This behavior happens only when I have a long list, like 50 items or more..

我用这样的方式绑定LongListSelector上的项目:

I bind the items on LongListSelector this way:

XAML:

<Grid x:Name="ContentPanelContatos" Grid.Row="1" Margin="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >
    <Grid x:Name="gridContatos" Grid.Row="1" Margin="12,2,12,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Grid Grid.Row="0" Margin="0,0,0,12" >
            <TextBox x:Name="tbxSearch" VerticalAlignment="Top" HorizontalAlignment="Stretch" Visibility="Collapsed" TextChanged="TbxSearch_TextChanged" LostFocus="TbxSearch_LostFocus" Style="{StaticResource TextBoxStyle}" />
        </Grid>

        <phone:LongListSelector Grid.Row="1" x:Name="llsContacts" ItemsSource="{Binding}"  SelectionChanged="llsContacts_SelectionChanged" >
            <phone:LongListSelector.ItemTemplate>
                <DataTemplate>
                    <ListBoxItem local:TiltEffect.IsTiltEnabled="true">
                        <Grid Margin="0,0,0,10" >
                            <TextBlock Text="{Binding NAME, Mode=TwoWay}" FontFamily="Segoe WP" FontSize="28" Margin="77,0,0,0" />
                            <TextBlock Text="{Binding Path=NUMBER, Mode=TwoWay}" FontFamily="Segoe WP Light" FontSize="17" Margin="77,33,0,0"/>
                        </Grid>
                    </ListBoxItem>
                </DataTemplate>
            </phone:LongListSelector.ItemTemplate>
        </phone:LongListSelector>       
    </Grid>

    <!-- more 2 grids with contents -->
</Grid>

我使用ObservableCollection绑定项目,我遇到了这个问题..然后我试图删除列表并再次绑定它(在搜索之后)这样:

I was binding the items using ObservableCollection and I was having this problem.. Then I tried to erase the list and bind it again (after the search) this way:

if (llsContacts.ItemsSource != null)
    llsContacts.ItemsSource.Clear();

llsContacts.DataContext = daoRd.GetData();

但我仍然遇到这个问题.. 。

But I'm still with this problem...

有人能告诉我发生了什么吗?
b $ b我做错了吗?

Does anybody can tell me what is happening?
Am I doing something wrong?

阅读本文:
Windows Phone中的帧速率计数器
,我注意到当出现此问题时,调试时屏幕一侧的数字停止变化...

Reading this article: Frame rate counters in Windows Phone, I noticed that when this problem happens, some of the numbers that are on the side of the screen when debugging, stops changing...

他们这样停止:



用户界面线程FPS:000
$
纹理内存使用量:007181
$
表面计数器:050

中间纹理计数器:002

They stops like this:

User Interface Thread FPS: 000
Texture Memory Usage: 007181
Surface Counter: 050
Intermediate Texture Counter: 002

这个数字是否意味着什么?

Does this numbers means something?

推荐答案

您是否转储了从daoRD.GetData()返回的内容?  可能是该集合中的一个项目有空字符串吗?  另外我注意到在设置DataContext之前清除了ItemsSource。 如果您在此之后立即设置DataContext,则可能不需要
have you dumped the contents of what is returned from daoRD.GetData()?   Could be one of the items in the collection has blank strings?   Also I noticed you clear the ItemsSource before setting the DataContext.  That is probably not necessary if you are setting the DataContext immediately after that.


这篇关于滚动LongListSelector的奇怪行为 - WP8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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