I am using would like to use WPF DataGrid to display a list of instances of e.g. a class Animal
that I store during the life of my application (say I add/remove animals to my list) in an attribute of my main Window
public List<Animal> _animals
public class Animal {
public int ID { get; set; }
public strng name { get; set; }
}
I added the DataGrid
to my XAML as such
<DataGrid Name="AnimalGrid"></DataGrid>
Then linked it to a function LoadAnimals()
when initializing my window :
AnimalGrid.ItemsSource = LoadAnimals();
public List<Animal> LoadAnimals() {
return _animals;
}
I want the Data grid to update/refresh. More precisely I pretty much only want the data grid to call LoadAnimal
function again. I have tried AnimalGrid.Items.Refresh()
but it does not work.
Any suggestions ?