I have a WPF application where I can add persons. They'll show up in a listview. Every time I add someone they appear. However, if I try too load a file the view will not refresh.
Persons = new List<Person>();
UsersListView.ItemsSource = Persons;
View = (CollectionView)CollectionViewSource.GetDefaultView(UsersListView.ItemsSource);
if (File.Exists("Persons.bin"))
{
Persons = (List<Person>) Utils.Deserialize("Persons.bin");
// The Persons list gets populated however, it doesn't show up in my view.
View.Refresh();
}
private void AddPersonButton_Click(object sender, RoutedEventArgs e)
{
if (ValidateInfo())
{
Person person = new Person(FirstNameTextBox.Text, LastNameTextBox.Text, Convert.ToInt32(AgeTextBox.Text));
View.Refresh();
Utils.Serialize(Persons, "Persons.bin");
}
}
When I add a person via the button they view will refresh and they appear, but when I close and open the application the persons will not show up ever if my Persons list is populated.