How to Bind ListView with string List: WPF

As we all know the listview is inherited class of listbox and have almost all the properties of listbox. We have learnt listbox binding with string list in our earlier post. In this article we bind the listview with the same string list.

Just place a listview having only name property, because we have to access that listview in our code behind file. We can also use height and width property of the listview, if the data items are of lengthy string.

Now use the same list of string as in previous post i.e.
List<string> strList = new List<string>();
listView.ItemsSource = strList;

Now look out the last statement, it will set the item source of the listview as this string list. When we run the project it will show a listview with four items:

Bind listview with string list in WPF C#

To get selected item the same procedure will follow as in listview bind with grid resource.
How to Bind ListView with string List: WPF How to Bind ListView with string List: WPF Reviewed by Subhash Sharma on September 08, 2013 Rating: 5

No comments