"Miles Journey--windows App development" Listview&gridview "patching"

Source: Internet
Author: User

As far as I am concerned, the list is very difficult, and this one we will break it up individually!

The listview displays the data in a vertically stacked manner, while the GridView uses a horizontal stacking method.

They're all pretty much the same.

<GridName="Grid1" Background="{ThemeResource Applicationpagebackgroundthemebrush}"> <listview x:name="ListView1"Selectionchanged="Listview1_selectionchanged"> <x:String>Item 1</x:String> <x:String>Item 2</x:String> </ListView> <gridview x:name="GridView1"Selectionchanged="Gridview1_selectionchanged"> <x:String>Item 1</x:String> <x:String>Item 2</x:String> </GridView> </Grid>

Of course, you can also add in the background code OH. I'm just trying to compare them together. Oh, these code heaps must be ugly together.

ListView ListView1 = new ListView ();ListView1. Items. ADD("Item 1");ListView1. Items. ADD("Item 2");ListView1. Items. ADD("Item 3");ListView1. SelectionChanged+ = Listview1_selectionchanged; Grid1. Children. ADD(ListView1); GridView GridView1 = new GridView ();GridView1. Items. ADD("Item 1");GridView1. Items. ADD("Item 2");GridView1. SelectionChanged+ = Gridview1_selectionchanged; Grid1. Children. ADD(GridView1); 

If it is just like the above to add content will be more trouble, we can also put these item 1, item 2 and so on all in the list yo.

 list<string> itemslist = new list<string> () 
    
      Itemslist
      ( "Item 1" )  Itemslist ( "Item 2" )  ListView ListView1 = New ListView ()  Listview1 = Itemslist;  Listview1 + = Listview1_selectionchanged Grid1  (listView1) ;  
     

This shows that the ListView is a two-line, very primitive, completely not able to meet the requirements. Then we can use its ItemTemplate property to add something, as shown below, we can write an image binding avatar in the grid, bind the user ID with TextBlock, and then a message that TextBlock bind the user, You can also write a border or something. And these messy binding what, we will also talk about it, now as long as they are data binding just fine.

    <page.resources>        <collectionviewsource x:name="Collectionvs" Source="{Binding Items } "/>    </page.resources>    <Grid Name="Grid1" Background="{ThemeResource Applicationpagebackgroundthemebrush} ">        <ListView x:name="ListView1"ItemsSource="{Binding source={ StaticResource Collectionvs}} "selectionchanged=" listview1_selectionchanged ">                        <listview.itemtemplate>                <DataTemplate>                    <Grid>                    </Grid>                </DataTemplate>            </listview.itemtemplate>        </ListView>          </Grid>

You can also use the Wrapgrid to determine how the item is placed, like so.

    <Grid Name="Grid1" Background="{ThemeResource Applicationpagebackgroundthemebrush} ">        <ListView verticalalignment="Bottom">            <listview.itemspanel>                <itemspaneltemplate>                    <wrapgrid Orientation="Vertical" maximumrowsorcolumns="2"/ >                </itemspaneltemplate>            </listview.itemspanel>            <Rectangle Height=" +" Width=" Fill" ="Wheat" />            <Rectangle Height=" +" Width= "+" Fill="White" />            <Rectangle Height=" +" Width=" +" Fill= "Gainsboro" />            <Rectangle Height=" +" Width= " Fill="Violet " />            <Rectangle Height=" +" Width=" +" Fill= "Darkblue" />            <Rectangle Height=" +" Width= " Fill=" Rosybrown " />            <Rectangle Height=" +" Width=" +" Fill= "SaddleBrown" />            <Rectangle Height=" +" Width= " Fill=" AliceBlue " />            <Rectangle Height=" +" Width=" +" Fill= "fuchsia" />            <Rectangle Height=" +" Width= "+" Fill="Aqua" />            <Rectangle Height=" +" Width=" +" Fill= "Tan" />        </ListView>    </Grid>

Of course, for the ListView and the GridView, it is important to know which one the user has chosen. The SelectionMode property determines the selection mode for the ListView and GridView: Single, multiple, none, and extended. The following function gives SelectedItems the selected item. We can also use isitemclickenabled to enable click events for the ListView and GridView, but be sure to set SelectionMode to none.

privatevoidlistView1_SelectionChanged(object sender, SelectionChangedEventArgs e){     selectedItems = (List<object>)e.AddedItems;   }    

(not to be continued and repaired)

"Miles Journey--windows App development" Listview&gridview "patching"

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.