Just as a background, I've attempted almost every suggestion on these forums for overriding the AppointmentDialogViewModel for the appointment edit screen and nothing has worked fully for my needs. I'm trying to adhere to MVVM, and that might be my mistake. At this point, either I get this to work, or I revert to handling the AppointmentEditing event in code and manually doing what I need there, but I would like to take advantage of how you guys have already handled the appointment editing.
I'm basically building the appointment edit screen from scratch, and I have drop downs that I need to populate. The data for those drop downs are in the ScheduleView.DataContext, but I can't find how to get that data into the AppointmentDialogViewModel so the appointment window will see it. That's why I figured I could use it as a base for my view model and all I needed to add was the data for the drop downs. If there is a better way, please let me know. Otherwise, can you tell me how to get the Occurrence object so the constructor would work?
Thanks!
10 Answers, 1 is accepted
base(Occurrence.CreateOccurrence((CustomAppointment)scheduleView.SelectedAppointment, scheduleView.SelectedAppointment.Start, scheduleView.SelectedAppointment.End), AppointmentViewMode.Edit, host, (IEnumerable<
IResourceType
>)scheduleView.ResourceTypesSource, (IEnumerable<
ITimeMarker
>)scheduleView.TimeMarkersSource, categoryList)
I used this call to the base constructor. It seems to be working really well, I don't need to recreate the code from AppointmentDialogViewModel when I use this approach and I can have my own properties for the Appointment Dialog View Model.
The problem I'm having now is that the AppointmentEdited and AppointmentCreated events aren't getting fired when the Appointment Dialog is confirmed. Instead, it only fires when I go to edit another appointment. This is a problem since my changes aren't getting saved to the database and the view isn't being updated with the changes until I go to change the date or edit another appointment.
This works fine if I drag and drop, or if I stop using the DialogHostFactory. Unfortunately, I can't assign my custom AppointmentDialogViewModel if I don't use the DialogHostFactory.
Is there something not obvious I need to do with the confirm of the AppoinmentDialog to make sure the AppointmentEdited event gets fired? I've tried calling Occurrence.Appointment.EndEdit() and that doesn't trigger it either. So there is something not obvious that I need to do. Please help, this is a major problem for me now.
I suggest you not to inherit and replace the AppointmentDialogViewModel with your custom view model, but
using it internally to complete the task. Please find the project attached for more details.
Regards,
Rosi
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
I found a fix, it isn't pretty but my stuff is working now.
I would like to request that a future version would allow us to extend the AppointmentDialogViewModel class without breaking a lot of stuff.
We are glad that you resolve the issue yourself.
We will consider extending the view model of the RadScheduleView dialogs. One thing that we are considering is adding a new property of type object to the AppointmentDialogViewModel class. Then in the event handler of the ShowDialog event you will have the ability to set an instance of your class to this property and bind to it in the dialog. Does this sound useful to you? We will be glad to hear your opinion.
Regards,
Rosi
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
Like I mentioned in my original post, I have a few combo boxes for an appointment that aren't really resources. Those drop downs are populated by a set of collections that I populate in my ScheduleView view model. I don't need the whole VM, but with the object implementation, I think that's what I would need to do, assign the ScheduleView view model to the object property. I'm just not sure how binding the combo boxes would work out at that point.
I think just being able to use AppointmentDialogViewModel as a base class would be the most flexible solution.
I've seen others on the board request the same kind of capability, hopefully they will see this post and post their feelings.
Extending the dialog ViewModel to be inherited requires a lot of changes in RadScheduleView control.That is why we have plans to introduce the mechanism that I described in the previous message for the upcoming Service Pack next month.
I will try to explain it once again with an example:
In the AppointmentDialogViewModel we have plans to add new property similar to:
private object additonalData;
public
object
AdditionalData
{
get
{
return
additonalData;
}
set
{
additionalData = value;
OnPropertyChange(
"AdditionalData"
);
}
}
Then In the ShowDialog event you will have the ability to set the all additional data that you need to be displayed in the dialog like:
public
class
MyData
{
public
IEnumerable <
object
>ComboItemsSource
{
get
;
set
;
}
}
public
void
ShowDialog (
object
sender, ShowDialogEventArgs args)
{
e.ViewModel.AdditionalData=
new
MyData();
}
and the binding in the template of the edit dialog will be something like:
<
telerik:RadComboBox
ItemsSource="{Binding AdditionalData.ComboItemsSource}"/>
If this mechanism does not met the requirements of most common scenarios we will consider changing the logic for the major Q3 2011 release.
Greetings,
Rosi
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
Thanks!
Please can you confirm if the "AdditionalData" property has been added to the ScheduleView control?
If it has, please can you send details of how it works.
Thanks
Tessa
The feature does not come out-of-the-box in the current version. We’re considering your request, however, we started a major undertaking several months ago and we had to relocate the resources for that new initiative – the GanttView control. We will do our best to include it for the upcoming service pack by the end of March. Please,excuse us once again for misleading you.
Rosi
the Telerik team