Is there a way to mark special dates in a calendar, as in example “DatePicker with special dates”, where my special dates wouldn’t be hardcoded as here?
IEnumerable<DateTime> dates = new DateTime[] { DateTime.Today.AddDays(-1), DateTime.Today.AddDays(1) };
Instead I’d like to pass a list of dates as a parameter from the parent page, or by calling a method inside the OnInitializeAsync().
Unfortunately, nothing I tried worked. It seems that calendar gets rendered before the OnInitialized method, and I cannot find the way to re-render it, with the selected dates highlighted.
Any idea if that is even possible, or how to make it work?
int taskId = 7;
IEnumerable<DateTime> dates = new List<DateTime>();
void DateRenderSpecial(DateRenderEventArgs args)
{
if (dates.Contains(args.Date))
{
args.Attributes.Add("style", "background-color: #ff6d41; border-color: white;");
}
}
protected override async Task OnInitializedAsync()
{
dates = await projectService.GetAllScheduledTaskDates(taskId);
}