I have a listview for which the items gets added at run time in form of a grid with single/multiple columns. Now I need to get the sort working. Once the list view has items in it and they click on the column it should sort it on that column.
Below is the code for the listview
<ListView Name="lstValue" Margin="0,0,0,10"></ListView>
C# code where it populates the list view:
case "Person":
dt = GetDataTable(GET_Person)
this.lstValue.View = gridview;
gridview.Columns.Add(new GridViewColumn { Header = "Number",
DisplayMemberBinding = new Binding("Number") });
gridview.Columns.Add(new GridViewColumn { Header = "Name",
DisplayMemberBinding = new Binding("Name") });
foreach(DataRow dr in dt.Rows)
{
this.lstValue.Items.Add(new ReportItem { Number = dr["Number"].ToString(),
Name = dr["Name"].ToString() });
}
break;
They should be able to sort on name or number.