public CalendarEventCollection CalendarInlineEvents { get; set; } = new CalendarEventCollection();
public async Task Init()
{
ScheduleDayCache = await dataService.LoadScheduleDays();
foreach (var item in ScheduleDayCache)
CalendarInlineEvents.Add( CreateEvent(item) );
}
View:
FirstDayofWeek="1"
InlineViewMode="Agenda"
MaximumEventIndicatorCount="3"
SelectedDate="{Binding SelectedDate}"
ShowInlineEvents="False"
ShowNavigationButtons="True"
ViewMode="MonthView"
SelectionChangedCommand="{Binding SelectedDateChangedCommand}">
Version SfCalendar: 19.1.0.69
Sorry, forgot to mention the platform. Android seems ok but UWP is slow. I have also attached a sample project
And is there a reason why there is no
constructor to pass a complete list
to the
CalendarEventCollection?
Attachment: CalendarSample_273ce806.zip
|
internal void Init()
{
calendar.SuspendAppointmentUpdate();
for (int i = 0; i < 8; i++)
{
CalendarInlineEvent event2 = new CalendarInlineEvent();
event2.StartTime = DateTime.Now;
event2.EndTime = DateTime.Now.AddHours(i);
event2.Subject = i.ToString();
event2.Color = Xamarin.Forms.Color.AliceBlue;
CalendarInlineEvents.Add(event2);
}
calendar.ResumeAppointmentUpdate();
} |
Hi,
your sample is working. But in my app the performance is not improved. I still check the differences. Maybe because the calendar is used in a more complex layout (with bottom navigation/tabbedpage)
Generally I do not like the solution. I have to add code to the view or pass a control to my viewmodel. This breaks MVVM.
So why do you hide the constructor
public ObservableCollection(IEnumerable<T> collection);
This would be a better solution.
Best Regards
Bernd
Setting it isVisible=false did the trick.
protected async override void OnAppearing()
{.....
progressBar.IsVisible = true;
calendar.IsVisible = false;
await ViewModel.Init();
progressBar.IsVisible = false;
calendar.IsVisible = true;
.....
The progressBar is not displayed at all because the loading is very fast as long as the calendar is invisible.