Building Apps for Windows Phone 8.1: (04) Lists and Lists Items in Windows Runtime Apps

Download this episode

Download Video

Download captions

Description

Embed

Format

Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • User profile image
      arko

      Could you please tell me how to save and restore the listview "scroll position" when no item is selected? Is there a way to access the items that are currently "visible"?

    • User profile image
      matthiasS

      arko,

      It's a little roundabout, but you can use the ItemsPanel to find the index of first visible item in the list. From there you can get the container for that item and from that container you can get the item. You can use that item to scroll to the correct position.

      var isp = (ItemsStackPanel)SampleListView.ItemsPanelRoot;
      int firstVisibleItem = isp.FirstVisibleIndex;
      var container = SampleListView.ContainerFromIndex(firstVisibleItem);
      var item = (MyObject)SampleListView.ItemFromContainer(container);
      SampleListView.ScrollIntoView(item);

    • User profile image
      Anand

      Great video! I am developing an app where I am trying to implement pull to refresh functionality using list view. I posted the question on windows Phone forums but haven't received a solution. Can anyone please help me with that.

      http://social.msdn.microsoft.com/Forums/en-US/4e1b69c3-ee92-4d96-8740-2db086e4274b/listview-manipulatindelta-event-not-firing?forum=winappswithcsharp

    • User profile image
      dubem

      Hello, can you please help me with a better solution to search a Listview OR Gridview. During the search I would like to hide the non matches, and show the matches. I currently have a solution, but its really slow once the list start getting really big.

    • User profile image
      arko

      @matthiasS: Thank you. I will try this as soon as I'm finished translating my WP8.0 code to WP8.1.

    • User profile image
      arko

      Took me a while to figure out the VB translation of the linq query. Maybe posting it here will save others some time:

      Dim groupedItems As New List(Of KeyedList(Of String, SampleItem))
      
      Dim gruuppi = _
                  From item In items
                  Order By item.TargetGroup, item.Title
                  Group By item.TargetGroup Into itemsByCompany = Group
                  Select New KeyedList(Of String, SampleItem)(TargetGroup, itemsByCompany)
      
      groupedItems = gruuppi.ToList
      
      Return groupedItems

      Oh and the source code for these videos can be found at Andy Wigley's OneDrive account [aka.ms/wp81jumpstartdemos].

    • User profile image
      arko

      How come the bindings to a CollectionViewSource work fine in run time but not in design time?

      To accomplish "groupedlist" functionality in WP8.1 must I bind to a CollectionViewSource or are there other options with design time support? Surely Microsoft does not expect us to start coding user interfaces blind like one used to before VISUAL studio?

    • User profile image
      matthiasS

      arko,

      What I normally do for design-time visuals is create a set of static data that I plan to use at design time and use the "d" designation. Example:

      First add the d xml namespace:

      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

      Then set d to be ignored on runtime:

      mc:Ignorable="d"

      Then set your design time DataContext in the XAML with the d prefix

      d:DataContext="{Binding MyDesignViewModel}"
      \

      With that, you can use a simple list of lists for design purposes and you won't have to use the CollectionViewSource.

    • User profile image
      matthiasS

      @dubem: Without knowing the details of your solution, my guess is that you would actually want to keep all of your items in a "AllItems" collection in your ViewModel and bind your ListView or GridView to a "SearchResultsItems" for the ItemsSource. You could then add or remove the items from that second ObservableCollection in your ViewModel rather than try to do the add-remove within the control.

    • User profile image
      arko

      , matthiasS wrote

      -- you can use a simple list of lists for design purposes and you won't have to use the CollectionViewSource.

      This is good news. I had the impression that CVS was a must with "groupedlists".

      Currently I am working on a simple-test-app just to get started. Here is the working xaml and code behind from VS2012-WP8.0-app plus what I have for VS2013-WP8.1-WinRT so far: http://postimg.org/image/5240r5wsx/full/

      The 8.1 app does not work even in runtime. What changes are required to my xaml or code behind as migrating my simple-test-app from 8.0 to 8.1 WinRT?

    • User profile image
      arko

      Finally managed to get my grouped list sample working both design and run time.

      Here is the final code: http://postimg.org/image/hfrk4hxux/full

       

    • User profile image
      goaty1992

      Dear,

      I downloaded the sample codes and tested them in my Lumia 525 running developer Preview 8.1

      When I run the grouped list view template, the group headed keeps bouncing up and down.

      Is it just me or is it because of the developer preview version of the OS?

      And also I have the feeling that lists in Silverlight apps run much smoother and render much faster.

    • User profile image
      Sushma

      I want to implement panning and zooming in my app,where a user can pan and a zoom a video .How can i do that ?

    • User profile image
      become90

      where can I get the project example of this section?

    • User profile image
      matthiasS

      @Sushma,

      My recommendation for panning and zooming a video would be to either
      1) Put the video into a Scrollviewer and see if that does it

      2) Use the Player Framework media player (http://playerframework.codeplex.com/) an enormously flexible media player that works on all recent versions of Windows and Windows Phone.

    • User profile image
      matthiasS
    • User profile image
      become90

      thanks,


      I got some problem to implement this grouped listview for json file in local folder
      any reference how to use this method for non static data?

    • User profile image
      Sasa

      Great video!

      I have been looking a way to change a background of the selected item in ListView. So, when I press the item, the background of that item will change. It sounds simple, but I am confused which to change in the default ItemContainerStyle.

      I presumed the state that I should look into is "pressed". However, when I changed the background, it will only change the background of the tilt animation. How can I remove away the tilt animation and simply change the background of the selected item. FYI, I also set the background of each item in the DataTemplate; well, just in case it would affect the treatment.

      Thank you.

    • User profile image
      matthiasS

      @Sasa: Because of the complex nature of the ListView, it uses a ListViewItemPresenter control in the ItemContainerStyle. This controlt has a LOT of brushes attached to it. If you change the SelectedBackground and SelectedPointerOverBackground, that should change the background of the item when it is selected.

      I don't currently see an easy way to remove the tilt, sorry. 

    • User profile image
      VuKhanhUIT

      Hello everyone!

      I'm a student, I want to create an app that is music player, non-benefit purpose.

      But I can not afford. Guys can give me some help?

      "I want to get all file .mp3 extensions and show it on listview or gridview"

      Thanks guys!

       
       
    • User profile image
      LBN

      how do I get index of item that click in listview(I don not khown whay is allway=-1) my listview is set selectionmode=single

      please?

    • User profile image
      ben0bi

      I just want a list with simple text in it. Please explain EXACTLY how to do that. You explain that as if I knew how to generate a binding and stuff...I DON'T KNOW * about it.

      That line:
      ItemsSource="{Binding Source={StaticResource Items}}"

      is NOT in my ListView when I drag it into my app.

      I don't know how to generate a template or what to do here, please explain that too.

      Thanks.

    • User profile image
      Marios Katsis

      Very nice video!
      Is there a way to make the Items of the Grouped List View to be scrolled horizontally?

    • User profile image
      torg

      Any time you tell me to design my UI by opening up a TEXT EDITOR to enter XAML by hand you have failed me.

      This whole series of videos in unique in that you can spend 30 minutes watching hoping to learn something, but don't really learn anything because you guys just apply things you've already created.

       

       

    • User profile image
      meethitesh28

      Hello Everyone,

      I want to save some client data with its respective image. For storing image, I've converted bitmap image into byte array and stored that array in database but while displaying all records, I want to display respective image for particular client in list view.

      I've checked example but in that images are coming from folder and not from database. 

      Please share if anyone has example.

      Thanks,

      Hitesh

    • User profile image
      san pandit

      Hi,
      Thanks for the tutorial its really great video for listview.
      Please tell me how i can make a expandable listview.

      Thanks,
      San K

    • User profile image
      Casy

      @matthiasS:

      Hi, I cannot download the sample code for these projects,could you please send me a mail of that.

      thanks.

      cceasy@hotmail.com

    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.