I hope my title isnt too misleading, but heres a quick explanation. As mentioned in the title im using WPF and I set the Itemsources of a Listbox to an ObservableCollection. I also made a DataTemplate for it to show the values correctly. However my problem is that when im changing the values in the ObservableCollection it doesnt show in the listbox. The question is now, what am I doing wrong?
Heres the code:
public ObservableCollection<Employee> employees;
employees = DatabaseControl.GetEmployees();
Employee_ComboBox.ItemsSource = employees;
Then im switching out the whole Collection:
private void save_Employee_Click(object sender, RoutedEventArgs e)
{
deactivateEmployee();
if (isnewEmployee)
{
DatabaseControl.AddEmployee(employee_firstName.Text, employee_lastName.Text, employee_phoneNumber.Text, employee_city.Text, employee_address.Text);
isnewEmployee = false;
}
if (updateEmployee)
{
DatabaseControl.UpdateEmployee(((Employee)Employee_ComboBox.SelectedItem).ID, employee_firstName.Text, employee_lastName.Text, employee_phoneNumber.Text, employee_city.Text, employee_address.Text);
updateEmployee = false;
}
employees = DatabaseControl.GetEmployees();
Employee_ComboBox.ItemsSource = employees;
}
But this doesnt seem to work out as it should. So what am I doing wrong here? GetEmpoyees() returns an ObservableCollection btw.