The ListView control lets you customize the default look and behavior of the control by using the ItemTemplate property.
Let's understand this by using an example. Here, we define the ItemTemplate such that each listview item should consist of a grid with two columns, one for textblock and the other for progressbar.
Create a class. For example, we have created a sample class Tasks.
C# |
Copy Code
|
---|---|
public class Task { public string TaskName { get; set; } public int Status { get; set; } } |
Initialize a list in the MainWindow constructor, and add the items to it, and assign the list to the ItemsSource of the ListView.
Create the XAML code as given below between the grid tags for template.
Run the code and see the populated data in the listview items.