Visual Studio Community 2015 + SQLite + Entity Framework
The database has 2 fields: ID and ShipType
Class for mapping the database:
namespace ImperialFleet
{
public class ShipTypeClass
{
private string id;
private string type;
public ShipTypeClass(string id, string type)
{
this.Id = id;
this.ShipType = type;
}
public string Id { get; set; }
public string ShipType { get; set; }
}
}
Code to load the Listview
private void button_Click(object sender, RoutedEventArgs e)
{
List<string> shipList = new List<string>();
using (var db = new ImperialFleetDBEntities())
{
shipList = (from g in db.ShipsType select g.ShipType).ToList();
}
listView.Items.Clear();
foreach (string str in shipList)
{
listView.Items.Add(str);
}
xaml Listview
<ListView x:Name="listView" HorizontalAlignment="Left" Height="198" Margin="39,10,0,0" VerticalAlignment="Top" Width="446">
<ListView.View>
<GridView>
<GridViewColumn/>
</GridView>
</ListView.View>
</ListView>
How can I do to show the other column with the ID field?
(from g in db.ShipsType select g.ID).ToList()