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.