zoukankan      html  css  js  c++  java
  • LongListSelector 控件 在 wp7 和wp8中的不同之处

    众所周知,wp8中的LongListSelector集成到了Rom中。

    性能得到了提升,一些api也发生了变化。

    在这里总结一下,作为分享,也作为备忘。

    参考文献 Windows Phone 8 XAML LongListSelector

    1.首先能一眼看出来的,就是滑动时可以固定的,分组header了。

     这个原来我们都是放一个textblock在那个位置,滑动时根据可视区域所在的项目,然后赋给textblock值。
     现在省事多了。

    2. 还有原来很费事才能实现的网格模式。现在通过layoutmode设置了。

     3. 原来的分组模板变成了JumpListStyle,由模板变成了样式,刚开始这块弄得有点晕,这让编辑变得有些不方便了。
    为了方便记录下编辑好的样式,以后直接拷贝就好了。

     1 <phone:PhoneApplicationPage.Resources>
     2  <phone: JumpListItemBackgroundConverter x:Key="BackgroundConverter"/>
     3        <phone:JumpListItemForegroundConverter x:Key="ForegroundConverter"/>
     4 
     5         <Style x:Key="JumpListStyle" TargetType="phone:LongListSelector">
     6             <Setter Property="LayoutMode" Value="List" />
     7             <Setter Property="Margin" Value="12,12,0,0"/>
     8             <Setter Property="ItemTemplate">
     9                 <Setter.Value>
    10                     <DataTemplate>
    11                         <Border Background="{Binding Converter={StaticResource BackgroundConverter}}" 
    12                             Width="470" 
    13                             Height="70" 
    14                             Margin="6">
    15                             <TextBlock Text="{Binding Key}"
    16                                 Foreground="{Binding Converter= {StaticResource ForegroundConverter}}"
    17                               Font Family="{StaticResource PhoneFontFamilySemiBold}"
    18                                   FontSize="28"
    19                                 Padding="2"
    20                                 VerticalAlignment="Bottom"/>
    21                         </Border>
    22                     </DataTemplate>
    23                 </Setter.Value>
    24             </Setter>
    25         </Style>
    26 </phone:PhoneApplicationPage.Resources>
    View Code

    这里有一点值得注意的是 JumpListItemBackgroundConverter and JumpListItemForegroundConverter
    如果想设置可点击或不可点击的样式,可以用Disabled="Bisque" Enabled="Aqua"像下面这样

    <phone:JumpListItemBackgroundConverter Disabled="Bisque" Enabled="Aqua" x:Key="BackgroundConverter"/><phone:JumpListItemForegroundConverter Disabled="Azure" Enabled="BlueViolet" x:Key="ForegroundConverter"/>

    4.下面是官方给的一些属性,方法,和事件的变化。

    从Windows Phone Toolkit 7.1的属性中

    删除了

    • BufferSize
    • IsBouncy
    • IsScrolling
    • MaximumFlickVelocity
    • ShowListFooter/ShowListHeader

    修改了

    Windows Phone Toolkit 7.1

    Windows Phone 8 ROM SDK

    DisplayAllGroups

    Display all groups in the list whether or not they have items. Default is true.

    HideEmptyGroups

    Hide all groups in the list without items. Default is false.
    分组下没有项的话隐藏分组

    GroupItemTemplate

    JumpListStyle

    IsFlatList

    Gets or sets whether the list is flat instead of a group hierarchy. Default is true.

    IsGroupingEnabled

    Gets or sets whether the list is flat instead of a group hierarchy. Default is false. 分组展示需要开启此属性

    新增部分

    • GridCellSize
    • LayoutMode LongListSelectorLayoutMode { List, Grid };
    • ManipulationState
    public enum ManipulationState
    {
        Idle, // nothing is manipulating or animating
        Manipulating, // Gesture is being recognized, finger is down and any delta is received, drag/pan or flick
        Animating //No Gesture is currently happening, but there is some animation happening, like scroll animation or compression animation
    } 

    从Windows Phone Toolkit 7.1的方法中

    删除了

    • AnimateTo(object item)
    • CloseGroupView()
    • DisplayGroupView()
    • GetItemsInView()
    • GetItemsWithContainers(bool onlyItemsInView, bool getContainers)
    • ScrollToGroup(object group)

    从Windows Phone Toolkit 7.1的事件中

    删除了

    • StretchingBottom
    • StretchingCompleted
    • StretchingTop

    修改了

    Windows Phone Toolkit 7.1

    Windows Phone 8 ROM SDK

    ScrollingCompleted

    ScrollingStarted

    ManipulationStateChanged

    (coupled with ManipulationState property)两者合二为一了

    Link/Unlink

    ItemRealized/ ItemUnrealized

    With EventArgs including ItemKind

    C#
    1. publicclassItemRealizationEventArgs : EventArgs
    2. {
    3.     ///<summary>
    4.     /// The ContentPresenter which is displaying the item.
    5.     ///</summary>
    6.     publicContentPresenter Container { get; }
    7.  
    8.     ///<summary>
    9.     /// Gets the kind of item that is realized
    10.     ///</summary>
    11.     publicLongListSelectorItemKind ItemKind { get; }
    12.  
    13. }
    14. ///<summary>
    15. /// Different kinds of items that exists in LongListSelector
    16. ///</summary>

    可以看到,其实变化挺大的。

    wp 8 sdk中的LLS性能 明显要比之前提高了不少。

    当然 panorama,和pivot的性能也有了很大的提高,尤其是panorama的数据加载。

    最后微软建议我们用longlistselector代替ListBox(这种说法几乎到处可见)

    那么到底LLS比ListBox好在那里呢?请关注我的下篇文章。

  • 相关阅读:
    TensorFlow 官方文档中文版 --技术文档
    借助离散数学解决“哈弗大学智商测试”一题 --编程算法
    Python3文件操作1 --Python3
    ThinkPHP5.0完全开发手册 --技术文档
    JSON和Serialize数据格式的对比
    JSON格式简介
    Github的简易操作
    Python3之JSON数据解析实例:新闻头条 --Python3
    MySql常用函数 --MySql
    Git简易教程
  • 原文地址:https://www.cnblogs.com/beyoung/p/3511230.html
Copyright © 2011-2022 走看看