wp8.1 Study7:listview and GridView applications

Source: Internet
Author: User

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

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.