Hey,
I have a button that changes my appointment start and end times between UTC and Local to a slected Timezone. The button updates the appointments correctly but I cannot get the UI to update accordingly. I have noticed that a forum post from two years ago address' this problem but it did not look like a solution was found as I too am using MVVM.
Any suggestions?
Thanks,
Cameron
9 Answers, 1 is accepted
I suggest you edit the appointment's properties using the BeiginEdit() and Commit() methods as described in our documentation.
Another way to refresh the UI is by resetting the template as follows:
System.Windows.Controls.ControlTemplate template = this.ScheduleView.Template;
this.ScheduleView.Template = null;
this.ScheduleView.Template = template;
Hope this helps.
Regards,
Rosi
Telerik
Hey,
Thanks for that. Can I ask, why do the Appointments not update when I change the Start and Finish time in my viewmodel? I basically set the new Start and Finish time and call and OnPropertyChanged event against the observable collection but it does not update.
Thanks
Cameron
Appointment class uses an internal backup storage used for canceling the edit of the properties and implement IEditableObject interface. That is why you need to call the Commit method in order to update the default values of the appointment class.
If you implement a custom appointment and add regular Dependency properties for example CustomStart and CustomEnd and use them in the template changing them on propertychange will affect the UI immediately.
However in this case canceling the change of the property via UI will not be possible.
Regards, Rosi
Telerik
Hi,
Can you tell a little more about custom CustomStart and CustomEnd properties. Will it instead old (Start/End) properties? And how to use them in template. Maybe you can give an example. Because, as I understood from the posts above, it is not possible to update view (start/end of appointments in scheduler) without direct manipulations with scheduler (BeiginEdit() and Commit()) that is not good solution according to MVVM.
Best regards,
Andrey
Example of custom properties added to appointment and its template can be found here and here
Also please follow our documentation about Custom Appointment for more details.
Hope this helps.
Regards,
Rosi
Telerik
Hi,
Thank you for the answer. I understood all about custom appointments.
But the main question still remains: is there any way to update start and end of appointments in scheduler in the View without having access to this scheduler? or start and end of the appointment in in scheduler strictly attached to Start / End of IAppointment? I ask this because I do not have access to the View (so I can't use BeginEdit and Commit) and there is a need to update start and end of the appointments in scheduler.
Best regards,
Andrey
Using the BeginEdit() and Commit() methods is the approach that I suggest you to use.
However another thing that you can try is to update the properties of appointments without calling these methods and try removing the edited appointment and adding it again in the appointments source collection. This should do the trick.
Hope this helps.
Regards,
Rosi
Telerik
Hey,
Have you made sure that you have implemented the Copy() and CopyFrom() function in your custom appointment class?
public
override
void
CopyFrom(IAppointment other)
{
AppointmentModel appointment = other
as
AppointmentModel;
if
(appointment !=
null
)
{
this
.Start = appointment.Start;
this
.End = appointment.End;
}
base
.CopyFrom(other);
}
Then by updating the Start and End time of the appointment should refresh on the ScheduleView.
Regards,
CM
Thanks a lot for answers. Everything works fine.
Regards,
Andrey