Xamarin RadCalendar strange jumping behaviour

0 Answers 64 Views
Calendar
Andrey
Top achievements
Rank 1
Andrey asked on 27 Sep 2023, 01:10 PM | edited on 27 Sep 2023, 02:10 PM

Hi.

When we set the DayViewSettings DayStartTime and DayEndTime in runtime on appointments changes for a day, the RadCalendar control behaves strange, jumping from day to day.

   TimeSpan dayStartTime = todayAppointments.Min(next => next.StartDate.TimeOfDay);
                    TimeSpan dayEndTime = todayAppointments.Min(next => next.EndDate.TimeOfDay);
                    calendar.DayViewSettings.DayStartTime
                        = calendar.MultiDayViewSettings.DayStartTime
                        = dayStartTime > defaultDayStartTime ? defaultDayStartTime : dayStartTime;
                    calendar.DayViewSettings.DayEndTime
                        = calendar.MultiDayViewSettings.DayEndTime
                        = dayEndTime > defaultDayEndTime ? dayEndTime : defaultDayEndTime;

Didi
Telerik team
commented on 27 Sep 2023, 02:11 PM

Hi Andrey,

Could you please attach the project to the forum, or open a support ticket and attach the project to it. I have removed the google link you shared here. In order to reduce the file size, delete bin and obj folders from all projects. Then archive the file and attach it to the ticket/forum

I have changed the product for this forum thread to Calendar / UI for Xamarin, as it was logged for Calendar / UI for .NET MAUI

Andrey
Top achievements
Rank 1
commented on 27 Sep 2023, 07:33 PM | edited

Hi. I can easily repro the issue with Day View mode, please see the project attached, just try to navigate the dates. 

Workaround - for example you can put the RadCalendar into the grid and will readd it as a child in codebehind after the detail timerange changes.

Thanks.

Didi
Telerik team
commented on 28 Sep 2023, 11:24 AM

Hi Andray,

Thank you for the provided project. I have reproduced the behavior. Could you please share what is the exact scenario you want to achieve? Having different start and end time for different dates?

Andrey
Top achievements
Rank 1
commented on 28 Sep 2023, 11:26 AM

Hi.

Yes, let's say we have many appointments with the different start and end time, so each DisplayDate change we must evaluate the start and end time from related appointments and set it to the calendar.

Thanks

Didi
Telerik team
commented on 28 Sep 2023, 04:17 PM

Hi Andrey, 

Thank you for the provided scenario.

I have another suggestion: You can keep the current state of the time line and set fixed start and end time in the xaml, then use the scroll to appointment method https://docs.telerik.com/devtools/xamarin/controls/calendar/calendar-scrolling#scrollappointmentintoview-method to scroll to a concrete appointment (first in the collection). Let me know whether this is an option for you.

Andrey
Top achievements
Rank 1
commented on 28 Sep 2023, 05:47 PM

Hi Didi , thats the option with 00:00 to 12PM timeframes for each date, look not so logical in UI, also where I would scroll if I have multidays view mode, currently we r tricky adjust the timeframes as well?

Thanks.

Didi
Telerik team
commented on 03 Oct 2023, 02:06 PM

Hi Andrey,

You can define the start and end time of the time of the DayView: 

   <telerikInput:RadCalendar.DayViewSettings>
       <telerikInput:DayViewSettings
           DayStartTime="06:00:00"
           DayEndTime="23:00:00"
           TimelineInterval="2:00">
       </telerikInput:DayViewSettings>

When scroll to appointment on selection changed: 

  private void calendar_SelectionChanged(object sender, Telerik.XamarinForms.Input.Calendar.CalendarSelectionChangedEventArgs<object> e)
  {
      if(this.calendar.AppointmentsSource != null)
      {
          Device.BeginInvokeOnMainThread(() => {
              var app = (calendar.AppointmentsSource as ObservableCollection<Appointment>).First();
              calendar.ScrollAppointmentIntoView(app);
          });
       
      }
  }

xaml and cs files are attached. I hope this will be of help.

The approach is applicable for DayView mode. For MultiDay, you do not have a selection in the days area. You can use the display date changed event. 

Andrey
Top achievements
Rank 1
commented on 03 Oct 2023, 02:09 PM

Hi Didi, could we expect the fixed RadCalendar behaviour mentioned before in the new releases?

The proposed solution does not cover our needs at the moment.

Many thanks.

Didi
Telerik team
commented on 06 Oct 2023, 11:22 AM

Hi Andrey,

There isn't a time-frame when the behavior will be solved. You can use the suggested workaround, it uses the SelectionChanged and scrolls to the first appointment in a DayView mode.

In addition the SelectionChanged does not fire for multiday view and such scenario is not valid for multi day, you cannot change the timeline start and end dates as there are several days and appointments in these days The timeline is common for all the days. You can use the DisplayDateChanged event and scroll to the first appointment when date changes. 

No answers yet. Maybe you can help?

Tags
Calendar
Asked by
Andrey
Top achievements
Rank 1
Share this question
or