Hello,
currently we are saving the appointment inside of our CustomAppointmentDialog.
ActivityOperationResult result = dlg.DataManager.EndEdit(dlg.Activity, true);
Appointment = result.Activity.DataItem as AppointmentInfo;
//DoStuffWithAppointment
dlg.UpdateDirtyStatus(false);
The problem is when I change something else, the dialog is dirty again and from my understanding the OnActivityChanging code will run again once we save in the dialog.
However, the DataItem from the ActivityChangingEventArgs for the "ActivityChanging" event does not have the values from the first time we saved and the DataItem is not known inside my main DataManager. Even when we changed it earlier with my method.
I hope you understand what I mean. It is kind of a complex program with database access, so it's not that easy to provide accessible code that you can run. However, if you can do live support, I'd be interested in that.
Best regards
Hi Tegos,
Not sure what your setup is like so this may not be helpful at all but have you implemented INotifyPropertyChanged on your AppointmentInfo class? If you are changing properties on there that are mapped to the Appointment class properties then once a property notification is detected the Appointment should update accordingly.
Hi Rob,
thank you for your answer. Yes of course I've implemented it. However that is not working.
So this is what I think what happens: When I edit a new appointment, it is in the appointment dialog as a "temporary record". And now when I save it manually (see code above), the record will still be the temporary record after saving. So it does not contain any of the data, that gets written into the record the first time we saved. Now when I save the appointment again (save & close) it won't have any of the changes that I made earlier with my manual save.
Hope you understand what I'm talking about.
The ActivityChanging event is a result of the DataManager.EndEdit call. However, the second time this event fires after making another change I can see that the Activity itself has not updated with my previous change, however if I inspect the Activity.DataItem (AppointmentInfo object) then I can see that my change was applied. I believe you are correct that the dialog is working with a copy of the activity and it will not be updated until you close the dialog and open another dialog for the same activity. Or if you modify the Activity properties instead of the AppointmentInfo properties. Generally though, I would imagine that after you save the settings you should just close the window. If subsequent changes need to be made then users can just open another dialog for that same appointment like in Outlook.
thank you for your answer. I will restructure my worflow so the customer has to reopen the dialog in case he needs to edit more fields on the appointment.