private void EditProfileViewModel_EnhancedPropertyChanged(object sender, EnhancedPropertyChangedEventArgs <EditProfileViewModel> e) { if (e.IsProperty(p => p.Profile)) { UserProfile oldValue = e.OldValue as UserProfile; if (oldValue != null) { oldValue.EnhancedPropertyChanged -= Profile_EnhancedPropertyChanged; } UserProfile newValue = e.NewValue as UserProfile; if (newValue != null) { newValue.EnhancedPropertyChanged -= Profile_EnhancedPropertyChanged; newValue.EnhancedPropertyChanged += Profile_EnhancedPropertyChanged; newValue.CheckHasChanges(); } UpdateWindowTitle(); } }