Windows Phone 8.1 List control (1): basic

Source: Internet
Author: User

When it comes to List controls, the ListView and GridView are recommended on Windows Phone 8.1.

And the two controls are so much to talk about that they are divided into three articles:

(1) Basic

(2) Grouping data

(3) Multi-Data rendering

The biggest difference between the ListView and the GridView is that the ListView is arranged sequentially, while the GridView is a block in order, so one item in the ListView takes up an entire row or column, and the GridView Will only occupy the size it should have, and you can place multiple items in a row or column.

And the two are basically consistent in other aspects, so only the ListView is described below, the GridView is actually the same.

Template

(1) itemspaneltemplate

Itemspanel, which is the box that loads items, can customize its properties, such as allowing items to be arranged sideways:

< Listview.itemspanel >    < itemspaneltemplate >        <  Orientation= "Horizontal"/>    </  Itemspaneltemplate></listview.itemspanel>

(2) HeaderTemplate, FooterTemplate

Customize the head and tail of the list, such as adding a button at the bottom of the list to load more data:

<listview.headertemplate>    <DataTemplate>        <TextBlockText= "HeaderTemplate"Style="{StaticResource Controlheadertextblockstyle}"FontSize= " the"/>    </DataTemplate></listview.headertemplate><listview.footertemplate>    <DataTemplate>        <TextBlockText= "FooterTemplate"Style="{StaticResource Controlheadertextblockstyle}"FontSize= " the"/>    </DataTemplate></listview.footertemplate>

(3) ItemTemplate

The rendering of customizations (item) is important:

<listview.itemtemplate>    <DataTemplate>        <StackPanel>            <TextBlockText="{Binding Title}"Style="{StaticResource Listviewitemsubheadertextblockstyle}"/>            <ImageSource="{Binding Image}"/>            <TextBlockText="{Binding Content}"Style="{StaticResource Listviewitemcontenttextblockstyle}"/>        </StackPanel>    </DataTemplate></listview.itemtemplate>

(4) Itemcontainerstyle

Defines the behavior and rendering of controls in different states, which can be easily implemented using the SDK's own Blend.

2 Properties

(1) Multi-Select

Implementing multiple selections with XAML change SelectionMode:

Selectionmode= "multiple"

It can also be implemented through C # code:

Private void Multiplebutton_click (object  sender, RoutedEventArgs e) {    if( Mylistview.selectionmode = = Listviewselectionmode.single        )= listviewselectionmode.multiple    ; Else = listviewselectionmode.single;}         

(2) Sort

To turn on the sort state with XAML change Reordermode:

Reordermode= "Enabled"

It can also be implemented through C # code:

Private void mylistview_holding (object  sender, Holdingroutedeventargs e) {    if(E. Holdingstate = = holdingstate.started        )= listviewreordermode.enabled;}

Note that the next grouped data (groupingdata) you want to talk about cannot be sorted.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.