I can't seem to find an example of what I'm trying to do so I'm floundering around a bit.
I have a list:
public static List<Dinosaur> Dinosaurs = new List<Dinosaur>();
That is derived from:
public class Dinosaur { public string Specie { get; set; } public int Age { get; set; } public int Weight { get; set; } public double Height { get; set; } public int Health { get; set; } public double Water { get; set; } public double FoodConsumed { get; set; } public bool Sex { get; set; } public string PersonalName { get; set; } public System.Windows.Point Head = new System.Windows.Point(); public List<System.Windows.Point> Location { get; set; } public double Length { get; set; } public double Speed { get; set; } public byte State { get; set; } public System.Windows.Point Goal = new System.Windows.Point(); public System.Windows.Point[] FoodLocation = new System.Windows.Point[5]; // The last five locations that the dino found food public System.Windows.Point[] WaterLocation = new System.Windows.Point[5]; // The last five locations that the dino found water // Constructor public Dinosaur() { } }
And here's the XAML:
<Window x:Class="DinosaurIsland.ActiveDinosaurList" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="ActiveDinosaurList" Height="508" Width="212"><Window.Resources><DataTemplate x:Key="DinosaurInfo"><StackPanel Orientation="Horizontal"><TextBox Name="DinosaurName" Text="{Binding Path=PersonalName}"/><TextBox Name="DinosaurSpecies" Text="{Binding Path=Specie}"/><TextBox Name="DinosaurStatus" Text="{Binding Path=Status}"/><TextBlock Text="Energy" /><ProgressBar Name="Energy" /></StackPanel></DataTemplate></Window.Resources><Grid><ListView x:Name="DinoListView" Height="466" HorizontalAlignment="Left" Margin="0,3,0,0" VerticalAlignment="Top" Width="190" ><ListView.View><GridView><GridViewColumn CellTemplate="{StaticResource DinosaurInfo}" /></GridView></ListView.View></ListView></Grid></Window>
What I want is a list of all the dinosaurs in the dinosaur list with some of their features displayed (name, specie, health, etc.) and I want to be able to click on that 'record' (recognize which 'dinosaur' record was selected).
So, first question: How do I correctly bind the listview 'DinoListView' to the list 'Dinosaurs'?
Second question: How do I set it up so I can select a particular record?
Thanks!