Scheduler Loading on appointment template switching

0 Answers 57 Views
Scheduler
inLogic
Top achievements
Rank 1
inLogic asked on 04 Oct 2024, 09:20 AM | edited on 04 Oct 2024, 09:20 AM

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?

 

Yana
Telerik team
commented on 06 Oct 2024, 08:12 PM

I am afraid this wouldn't be an easy task as updating the template is executed on the UI thread and also showing any loading indicator (such as BusyIndicator) also takes the UI thread. Usually a loading indicator is shown while a long-running operation is executed in the background ( such as loading data from a service).

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.

No answers yet. Maybe you can help?

Tags
Scheduler
Asked by
inLogic
Top achievements
Rank 1
Share this question
or