/// <summary> /// Event handler that gets called when an employee info's property value changed. /// </summary> private void Employee_PropertyChanged(object sender, PropertyChangedEventArgs e) { var employeeInfo = sender as EmployeeInfo; /// Real world app would do database update operation here. var record = _model.GetRecord(employeeInfo.Id); if (record != null) { record.FirstName = employeeInfo.FirstName; record.LastName = employeeInfo.LastName; _model.UpdateRecord(record); } }
/// <summary> /// If employee info changed and is currently selected, make sure the displayed name and phone are updated too. /// </summary> private void Employee_PropertyChanged(object sender, PropertyChangedEventArgs e) { var employeeInfo = sender as EmployeeInfo; var record = _model.GetRecord(employeeInfo.Id); if (record != null) { record.FirstName = employeeInfo.FirstName; record.LastName = employeeInfo.LastName; _model.UpdateRecord(record); } // If the record is currently selected, also update the displayed info of the selection. if (employeeInfo.Id == SelectedId) { Changed(() => SelectedDetails); } }