Hi,
I use the RadCalendar control (Telerik UI for .NET MAUI ) and I have already implemented the customization of day cell (in month view mode), based on the following official sample,
More specifically I need to add a small circle color bubble/dot under the specific day label. The first time that calendar loads I need to load some "Appointments" called "FocusedMonthWorkingSchedules" as follows. Every time the user changes focused month I need to perform an HTTPs API call to update the list and so to update the calendar's cells asyncronously.
The problem is when user performs month change, the RadCalendar changes UI immediately (it is logical) and when the API call returns, there is no way to trigger the following override method "SelectStyle" because it has already completed n times. At the moment that "SelectStyle" method runs, the stored data inside the list (in the ViewModel) have not been updated yet until the API calls finish, so RadCalendar shows previous state.
public partial class CalendarViewModel : BaseViewModel {
public List<WorkingScheduleView> FocusedMonthWorkingSchedules;
public async Task GetFocusedMonthScedule(DateTime selectedDate){
..... // Business Logic
FocusedMonthWorkingSchedules = await _restService.GetSchedule(request);
.... // Business Logic
}
}
public class CustomCalendarStyleSelector : CalendarStyleSelector {
protected override Style? SelectStyle(object item, BindableObject container) {
var node = (CalendarNode)item;
DateTime? date = node?.Date;
IView? view = (container as RadLayout)?.Children.FirstOrDefault(x => x.GetType() == typeof(Label));
if (view is not null && possibleLabel is Label bubble) {
CalendarViewModel viewModel = App.ServiceProvider?.GetService<CalendarViewModel>();
WorkingSchedule? workingSchedule =
viewModel?.FocusedMonthWorkingSchedules?.FirstOrDefault( x => x.DateTime == date);
bubble.TextColor = workingSchedule?.BubbleColor;
}
}
}
So, is there any best practice to synchronize the data in the UI (RadCalendar), as soon as the https API call finishes?
I have two thoughts, but I cannot find some docs for these,
1. Is there any way to enforce RadCalendar to refresh (e.g. Refresh( ) command)? And if so, can I prevent the initial invokation of "SelectStyle" method n times to improve rendering performance?
2. Is there any way to "pause" the changing month rendering until the asyncronous Task (https API call) finishes? (I think this is a bad practice)
Final thoughts
I can understand that a possible solution could be to use some .NET MAUI handlers, in order to utilize Telerik API for RadCalendar. Is there any example available to implement it using RadCalendar?
Thank you in advance