locked
ListView, GridView or StackPanel

    Question

  • Hi,

    I want to present a list of information on a page. I would like it to look like the HOURLY FORCAST list found in the Windows Weather app. It has columns, a header and a static list (with alternating row background colour).

    I'm new to Windows Store and XAML apps, so was wondering what would be easier for me. Should I use a ListView, a GridView or a normal StackPanel. The list should be scrollable, but the items not selectable.

    I've look at the Windows Store 8.1 samples but couldn't find anything that looked like it might help.

    Any suggestions would be great.

    Thanks

    Graham

    Wednesday, April 30, 2014 9:16 AM

Answers

  • I'd do that with a ListView. The data template for each ow can be a grid with one row and columns for time, icon, forecast temp and precipitation, etc.


    A GridView would be horizontally oriented with tiles rather than rows, and a StackPanel would have static content rather than being databound to collection data.  
    Wednesday, April 30, 2014 12:06 PM
    Owner

All replies

  • I'd do that with a ListView. The data template for each ow can be a grid with one row and columns for time, icon, forecast temp and precipitation, etc.


    A GridView would be horizontally oriented with tiles rather than rows, and a StackPanel would have static content rather than being databound to collection data.  
    Wednesday, April 30, 2014 12:06 PM
    Owner
  • Thanks Rob. I must admit, that is how I started to do it.

    One further question though; how could I do an alternative row background colour on the item template and how can I remove the default click behaviour as I don't want the rows selected or marked with a small tick.

    As a stab in the dark, for the different row colours would I set the background in the itemTemplate to a converter that gives two static resource brushes based on being odd or even row number? That really does sound like I've just made something up doesn't it.

    Graham

    Wednesday, April 30, 2014 12:59 PM
  • If you just want to change a simple property like colour then using an converter for the background colour would be a good option.

    If you want to make larger changes (like switching the speaker's side in a chat log) then you would use a DataTemplateSelector and trigger the template off of item's index.

    Either way you'll need to encode the index into the data model so you can find it from the bound object.

    --Rob

    Wednesday, April 30, 2014 3:49 PM
    Owner