Scroll to non-working hours
In Xamarin.Forms, setting the StartHour and EndHour would hide non-working hours, but you could still scroll to them, and the cells appeared in a darker shade of gray. However, in MAUI, scrolling to non-working hours is no longer possible.
Is there a way to replicate the old behavior in MAUI?
Example:
new SchedulerDaysView
{
StartHour = 7,
EndHour = 19,
};
Hi Fabrice,
Thank you for contacting us. For customizing the non-working hour time slots, you can achieve your desired outcome using the TimeRegions property of DaysView. Here’s a code snippet for your reference:
|
this.Scheduler.DaysView.TimeRegions = this.GetTimeRegion(); private ObservableCollection<SchedulerTimeRegion> GetTimeRegion() { var timeRegions = new ObservableCollection<SchedulerTimeRegion>(); var currentDate = DateTime.Now.AddMonths(-3); var timeRegion1 = new SchedulerTimeRegion(); timeRegion1.StartTime = new DateTime(currentDate.Year, currentDate.Month, 1, 0, 0, 0); timeRegion1.EndTime = timeRegion1.StartTime.AddHours(7); timeRegion1.RecurrenceRule = "FREQ=DAILY;INTERVAL=1"; timeRegion1.Background = Brush.Gray; var timeRegion2 = new SchedulerTimeRegion(); timeRegion2.StartTime = new DateTime(currentDate.Year, currentDate.Month, 1, 19, 0, 0); timeRegion2.EndTime = new DateTime(currentDate.Year, currentDate.Month, 1, 23, 59, 59); timeRegion2.RecurrenceRule = "FREQ=DAILY;INTERVAL=1"; timeRegion2.Background = Brush.Gray; timeRegions.Add(timeRegion1); timeRegions.Add(timeRegion2); return timeRegions; } |
We have prepared a simple sample illustrating this and attached it for your reference. Please check our sample and let us know if you need any further assistance.
For additional details, please refer to our user guide documentation.
You can also customize the appearance of TimeRegions using the DataTemplate and DataTemplateSelector. For a step-by-step guide, please see our Knowledge Base articles:
How-to-highlight-the-working-and-non-working-hours-in-net-maui-scheduler-sfscheduler-days
How-to-customize-the-non-working-hours-timeslot-using-the-datatemplate-in-the-net-maui
How-to-customize-the-non-working-hours-timeslot-using-the-datatemplateselector-in-the-net
We trust that this information is helpful. If you need further assistance, please feel free to reach out.
Regards,
Vidyalakshmi M.
Attachment: MAUIScheduler_b7968f80.zip
Thanks Vidyalakshmi, that did it!
I changed currentDate to -30 years:
var currentDate = DateTime.Now.AddYears(-30);
I did not see any lags, do you think I can keep it that way ?
Regards,
Fabrice
Hi Fabrice,
Setting the current date to -30 years will not cause any lag.
If there is anything else we can assist you with, please feel free to let us know.
Regards,
Vidyalakshmi M.
- 3 Replies
- 2 Participants
-
FA Fabrice
- Oct 31, 2024 01:43 AM UTC
- Nov 1, 2024 01:00 PM UTC