I use this XAML code for the ListView:
<ListView>
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding Path=Flag}" />
<GridViewColumn Header="Name" DisplayMemberBinding="{Binding Path=Name}" />
<GridViewColumn Header="Ip Address" DisplayMemberBinding="{Binding Path=IpAddress}" />
</GridView>
</ListView.View>
</ListView>
And this is how I add items to the ListView:
ServerListItem item = new ServerListItem
{
Flag = "IL",
Name = "Sample Server",
IpAddress = "sample-server.com"
};
lvServerList.Items.Add(item);
Here is the ServerListItem class:
public class ServerListItem
{
public string Flag;
public string Name;
public string IpAddress;
}
The item is added to the ListView but all columns are empty. What should I do?