We noticed that switching appointmentTemplate the first time activeViewDefinition is set to week (from day) there is a long update/load time on the view, so we sought to insert a loading overlay. (activated by setting a boolean on viewmodel to true).
We switch the template by looking into PropertyChanged event with this method:
private void MScheduler_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == "ActiveViewDefinition")
{
if (MScheduler.ActiveViewDefinition != null)
{
if (MScheduler.ActiveViewDefinition.Title == "Day")
{
MScheduler.AppointmentTemplate = this.Resources["CustomAppointmentDataTemplate"] as DataTemplate;
}
else
{
MScheduler.AppointmentTemplate = this.Resources["CustomAppointmentDataTemplateWeek"] as DataTemplate;
}
}
}
}
However setting the boolean for the loading view just before appointmentTemplate = the weektemplate from resource.
Doesn't make it load until after the scheduler is done doing the updates needed.
So my question is, is there a better way to change the appointmenttemplate(so we avoid the 2-5 second freeze on the ui) or make a loading screen work so we can hide it?
I would like to ask you why you'd need to completely switch the template, are the two templates so much different? I am asking as may be other approaches to handle the scenario, for example, using converters. Would it be possible to send me more details on the exact use case you have?
I look forward to your reply.