2014-02-18 35 views
3

我在Windows Phone 8应用程序中有LongListSelector(在PivotItem)控件。我看到一个奇怪的行为。有时LLS停止滚动。像冻结一样,我无法滚动它。但我可以使用AppBar,Pivot,Button Back等,甚至GroupHeader和JumpList。它随机发生(到目前为止我没有发现规律性)并且经常发生。早些时候我经常使用LLS,但这些问题从来都没有。LongListSelector停止滚动并冻结

以下是LLS可以冻结的典型场景。

  1. 转到使用LLS的页面。
  2. 滚动LLS。
  3. 点击LLS项目并导航到其他页面。
  4. 回到LLS页面。
  5. LLS不滚动。

这个包也可以以其他方式发生。

亮点:

  • 我也不大集合结合LLS(我的收藏约10 - 50项(5组))。
  • 当LLS没有冻结时,它的工作速度非常快,没有混蛋。
  • 我有一个ListBox(1 - 6个字符串元素)在LLS项目中。
  • 我用DataTemplateSelector(as implemented here)
  • 剖析不显示响应较差,当LLS冻结

我的XAML:。

<phone:LongListSelector Name="LLSSimpleSearch" VirtualizingStackPanel.VirtualizationMode="Recycling" 
         ItemsSource="{Binding ListGroup}" 
         toolkit:TiltEffect.IsTiltEnabled="True" 
         Margin="12,0,-12,0"                 
         IsGroupingEnabled="True" 
         LayoutMode="List" 
         HideEmptyGroups="False"  
         GroupHeaderTemplate="{StaticResource LLSHeaderTemplate}" 
         JumpListStyle="{StaticResource LLSJumpList}" 
         ListFooterTemplate="{StaticResource LLSListFooter}">  

的ItemTemplate

<questionary:QuestTemplateSelector Content="{Binding}"> 
<questionary:QuestTemplateSelector.Template1> 
      <DataTemplate> 
       <ListBox></ListBox> <!-- ListBox with small collect--> 
      </DataTemplate> 
<questionary:QuestTemplateSelector.Template1> 

<questionary:QuestTemplateSelector.Template2> 
      <DataTemplate> 
      </DataTemplate> 
</questionary:QuestTemplateSelector.Template2> 

<questionary:QuestTemplateSelector.Template3> 
      <DataTemplate> 
      </DataTemplate> 
</questionary:QuestTemplateSelector.Template3> 

<questionary:QuestTemplateSelector.Template4> 
      <DataTemplate> 
      </DataTemplate> 
</questionary:QuestTemplateSelector.Template4> 
</questionary:QuestTemplateSelector> 

在CS:

LLSSimpleSearch.DataContext = GYSearchViewModel.Instance; 
GYSearchViewModel.Instance.Load(); 

视图模型

private ObservableCollection<Group<Quest>> _listGroup = new ObservableCollection<Group<Quest>>(); 
public ObservableCollection<Group<Quest>> ListGroup 
     { 
      get 
      { 
       return _listGroup; 
      } 
      set 
      { 
       if (value != _listGroup) 
       { 
        _listGroup = value; 
        NotifyPropertyChanged("ListGroup"); 
       } 
      } 
     } 

public Load() 
{ 
    MyDataSource.Load((r) => { ListGroup= r; }) 
} 

有点怪怪的?在这个代码中,有潜在的问题?如果需要,我准备提供更多评论。提前感谢您的建议。

UPDATE(问题的解决)

我不能肯定100%,但99%是在ListBox问题。

<questionary:QuestTemplateSelector.Template1> 
       <DataTemplate> 
        <ListBox ScrollViewer.VerticalScrollBarVisibility="Disabled"/> 
       </DataTemplate> 
<questionary:QuestTemplateSelector.Template1> 

我必须在列表中显示我的数据,我用ListBoxLLS。实验方式,经过长时间的测试,我发现了冻结的规律性。然后得出结论,在ListBox的问题。在问题属性IsHitTestVisible帮助。

<questionary:QuestTemplateSelector.Template1> 
        <DataTemplate> 
         <ListBox ScrollViewer.VerticalScrollBarVisibility="Disabled" 
           IsHitTestVisible="false"/> 
        </DataTemplate> 
    <questionary:QuestTemplateSelector.Template1> 

现在没问题。

回答

3

手机必须呈现的控件(或项目)越多,相对于显示的项目总数而言,速度越慢。在我正在研究的WP8窗口中,有50多个要呈现的项目会显着减慢应用程序的运行速度,直到我不得不重新设计这些事情的加载和显示方式。

无论是加载延迟问题还是显示问题,或者两者兼而有之。您需要确定瓶颈并确定哪些权衡会使操作快速无论如何。

尝试使用静态数据(已在电话应用程序中预先加载)加载控件,以查看其负载或屏幕加载(例如除法和征服类型的分析)。

+0

感谢您的建议,明天我会尝试将静态数据绑定到LLS并从项目中删除列表框。我会在后更新中介绍结果。 – Alexandr

+0

OmegaMan,我更新了我的帖子,认为我想出了问题。 – Alexandr

0

我不知道,如果我说的是对的 - 但只是为了

着想你取从互联网项目,并把它们添加到观察的集合到该longlistselector的绑定?你使用“等待”关键字?也许在OnNavigatedTo()方法中有一些繁重的处理?

如果是这样,从网络获取东西的过程可能在UI线程中运行,而不是在另一个线程中运行,或者某些其他任务不应该在前台运行时阻塞CPU--这意味着应用程序正在等待处理数据,并且CPU被阻止,直到所有数据都从网上获取 - 在此期间应用程序将无响应 - 您可以使用滚动数据透视表,使用appbar等,但我认为这些将被限制为只是用户界面行为 - 他们不会运作