Add images and text dynamically to a listview item RRS feed

  • General discussion

  • Hi all,

    What I want to do is to add a listview to my XAML file. Each row of the list contains an image and some text, which are the members of a custom class. When i click on a listview row(i.e. containing an image and text), the information must be displayed in a corresponding textblock.

    This image and text has to be lifted from a text file, so i have to dynamically add the content of the listview.

    ListView.Items.Add() doesn't seem to work.

    Does anybody have a complete solution?



    Wednesday, February 29, 2012 6:28 AM

All replies

  • Hi Ashi,

    Are you writing in C++ or C#? This is the C++ forum, but the syntax you are using looks more like C#.

    Either way, the general advice would be the same: create a collection of your objects and assign the ListView's DataContext to set up the data binding and Listview's DataTemplate to display the image and text. See Quickstart: Data binding to controls for an overview and the wizard generated apps for an example. You might also want to look at the ListViewSimple sample.


    Wednesday, February 29, 2012 6:44 AM
  • Hi Rob,

    Can I get a sample on how to dynamically bind data to a listview for C++?

    Each row of the listview contains info about a user contact- i.e. his image and name, which is loaded from a text file.

    Also, clicking on one row of the listview must diplay the details of the user in an adjacent textblock.

    I have tried a lot to accomplish this task but unable to do so. I need a sample for this in C++.

    Kindly help.




    Tuesday, March 6, 2012 7:16 AM