For list controls, WP8.1 is commonly used for ListView, GridView, and ListBox controls. The first two are inherited from the third one.
1. ListView Control
It shows a vertical list, as shown in. It is ideal for presenting data.
2. GridView Control
It is a control that displays data in rows and columns, and is arranged as follows. Typically used to display image-based data.
3, the templates of the control
Commonly used are HeaderTemplate, FooterTemplate, ItemTemplate. The code at the bottom of this article is relevant.
(There are also Itemcontainerstyle, Itemspanel
4. Properties: Reorder reordering
WP8.1: Mylistview.reordermode = listviewreordermode.enabled;
Win8.1: Mylistview.canreorderitems = false;
But grouped Lists (grouped list) cannot be reordered.
5, properties: A variety of selected multiselection
When Multiselection is turned on, the list changes to. Open the Multiselection code: Mylistview.selectionmode = listviewselectionmode.multiple;
6. Application Examples:
XAML Code:
<GridGrid.Row= "1"x:name= "Contentroot"Margin= "19,9.5,19,0"> <ListViewName= "View1"SelectionMode= "None"AllowDrop= "True"Candragitems= "True"isswipeenabled= "True"> <listview.headertemplate> <DataTemplate> <StackPanel> <CanvasHeight= " the"Background= "#962381E0"> <TextBlockText= "header"> <Textblock.foreground> <LinearGradientBrushEndPoint= "0.5,1"StartPoint= "0.5,0"> <GradientStopColor= "Black"Offset= "0"/> <GradientStopColor= "#FFF9F5F5"Offset= "1"/> </LinearGradientBrush> </Textblock.foreground> </TextBlock> </Canvas> </StackPanel> </DataTemplate> </listview.headertemplate> <listview.itemtemplate> <DataTemplate> <StackPanelOrientation= "Horizontal"> <TextBlockText="{Binding Id}"Style="{ThemeResource Listviewitemtextblockstyle}"Width= "+"/> <TextBlockText="{Binding Name}"Style="{ThemeResource Listviewitemtextblockstyle}"/> </StackPanel> </DataTemplate> </listview.itemtemplate> <listview.footertemplate> <DataTemplate> <TextBlockForeground= "Red"Text= "This is a good example of learning"/> </DataTemplate> </listview.footertemplate> </ListView> </Grid> </Grid> <Page.bottomappbar> <CommandBar> <Commandbar.secondarycommands> <AppbarbuttonLabel= "Appbarbutton"/> </Commandbar.secondarycommands> <AppbarbuttonName= "AllApps"Icon= "AllApps"Label= "Multiple Selection"Click= "Allapps_click"/> <AppbarbuttonName= "Viewall"Icon= "Viewall"Label= "Appbarbutton"Click= "Viewall_click"/> </CommandBar> </Page.bottomappbar>
The corresponding section C # code:
list<school> items =NewList<school>(); Public string[] str=New string[]{"Hua Nong","Chinese Laborers","Medium and large","Chinese teacher","Jinan Big","Guang Gong","Guang Wai","Broad","Deep Big","Guang TCM","South Medical University"}; Random Random=NewRandom (); for(inti =0; I < -; i++) {items. ADD (NewSchool {Id = i, Name = Str[random. Next (0,Ten)] }); } This. View1. ItemsSource =items, ... ..Private voidAllapps_click (Objectsender, RoutedEventArgs e) { if(View1. SelectionMode = =listviewselectionmode.multiple) {view1. SelectionMode=Listviewselectionmode.single; } ElseView1. SelectionMode=listviewselectionmode.multiple; } Private voidViewall_click (Objectsender, RoutedEventArgs e) { if(View1. Reordermode = =listviewreordermode.enabled) {view1. Reordermode=listviewreordermode.disabled; } ElseView1. Reordermode=listviewreordermode.enabled; } Private voidGotopage2_click (Objectsender, RoutedEventArgs e) {Frame.navigate (typeof(Page2)); } }
wp8.1 Study7:listview and GridView applications