We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Appointment template performance

Hello, 

i'm currently using Syncfusion sfSchedule to display appointments, shown in a Day / Week View.
I'm using a template selector to select a templates for DayView, and another for WeekView.

(using : https://help.syncfusion.com/xamarin/scheduler/data-bindings#customize-appearance-using-datatemplateselector )
This template selector shows a ContentView containing a single item : A Label with a formatted text.
My problem is than it take 1 second to switch from one week to the other, with only 5 appointments each day. My users are complaining about the schedule not being smooth.

I tried to use a LazyView to delay the loading, but it's content is never loaded in the sfSchedule.

What is the strategy to achieve smooth scrolling ? 

Please note that the creation of the FormattedString does not have an impact on the overall performance : It wasn't better  with a precalculation of the formattedString.


The code Month view provided by the AppointmentTemplate :

 <ContentView.Resources>
...
        <Style x:Key="InlineViewTitleStyle" TargetType="Label">
            <Setter Property="TextColor" Value="{StaticResource TextColor}"/>
            <Setter Property="FontSize" Value="{StaticResource LittleSize}"/>
        </Style>
    </ContentView.Resources>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms" ...>
    <ContentView.Content>
        <Label
            Padding="2,2,2,2"
            InputTransparent="True"
            BackgroundColor="{Binding Color, Mode=OneTime}"
            Style="{StaticResource InlineViewTitleStyle}"
            TextDecorations="{Binding IsCanceled, Converter={StaticResource BoolToStrikethroughConverter}, Mode=OneTime}"
            LineBreakMode="CharacterWrap"
            >
            <Label.FormattedText>
                <FormattedString>
                    <Span Text="{Binding ReservationCount, Converter={StaticResource ReservationCountToStringConverter}, Mode=OneTime}"/>
                    <Span Text="{Binding StartTime, Converter={StaticResource DateToShortTimeStringConverter}, Mode=OneTime}"/>
                    <Span Text=" "/>
                    <Span Text="{Binding Name, Mode=OneTime}"/>
                    <Span Text=" "/>
                    <Span Text="{Binding IsRepeated, Converter={StaticResource BoolToRepeatIconConverter}, Mode=OneTime}"
                          FontFamily="{x:Static helpers:FontFamilies.FontAwesome_Solid}" />
                </FormattedString>
            </Label.FormattedText>
        </Label>
    </ContentView.Content>
</ContentView>

4 Replies

MS Muniappan Subramanian Syncfusion Team January 13, 2023 12:10 PM UTC

We have investigated the reported issue of "Delay in loading appointments in the schedule with custom appointment view." Based on our analysis of the schedule implementation, we have converted the forms view to a native view. However, there is a framework issue with the view conversion from the forms view to the native view, which makes the conversion slow and affects the schedule control appointment loading performance while using a custom view. We have improved the performance of the schedule and you will no longer experience this delay with the default Schedule appointment view.


We have already reported this issue to Xamarin, and we will update our implementation as soon as we receive a solution from the team. We apologize for any inconvenience this may have caused and appreciate your patience in the meantime.


Please refer to the following link for more information on this issue: https://github.com/xamarin/Xamarin.Forms/issues/4371


Please let us know if you have any further concerns.



AF Alban Favre January 13, 2023 02:44 PM UTC

Thank you for your reply.

Too bad no real fix is available. 

I see that a possible workaround to achieve better performance is by using SkiaSharp : draw text directly in a Canvas.

It looks heavy and a loss a time to do it from start. Do you have an exemple of this workaround ?

For exemple by drawing a complex FormattedString in a canvas ?

 

If not, I will simply keep my own better-but-not-perfect workaround : 

Do not set the Formatted text of the label by default. This operation takes too much time.


<?xml version="1.0" encoding="UTF-8"?>
<!--An appointment cell displayed in the schedule when in WeekView-->
<ContentView ...>
    <ContentView.Resources>
...
        <Style x:Key="InlineViewTitleStyle" TargetType="Label">
            <Setter Property="TextColor" Value="{StaticResource TextColor}"/>
            <Setter Property="FontSize" Value="{StaticResource LittleSize}"/>
        </Style>
    </ContentView.Resources>
    <ContentView.Content>
        <Label x:Name="myLabel"
            Padding="2,2,2,2"
            InputTransparent="True"
            BackgroundColor="{Binding Color, Mode=OneTime}"
            Style="{StaticResource InlineViewTitleStyle}"
            TextDecorations="{Binding IsCanceled, Converter={StaticResource BoolToStrikethroughConverter}, Mode=OneTime}"
            LineBreakMode="CharacterWrap"
            >
            <!--The following formatted text is loaded in background because it is too slow on Android.
            See https://www.syncfusion.com/forums/179973/appointment-template-performance-->
        </Label>
    </ContentView.Content>
</ContentView>


And on the code-behind : 

 public ScheduleAppointmentViewModel ViewModel => BindingContext as ScheduleAppointmentViewModel;
 public ScheduleAppointmentWeekView()
        {
            InitializeComponent();
            // Defer loading of Text of 250 ms
            Device.StartTimer(TimeSpan.FromMilliseconds(250), () =>
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    this.myLabel.FormattedText = ViewModel.FormattedTextForWeek;//<-- Set the Text value.
                });
                // Do not repeat. Loading is performed once only.
                return false;
            });
        }


KM Karthick Mani Syncfusion Team January 16, 2023 09:04 AM UTC

Hi Alban Favre,

#Regarding Custom Appointment template view causing delays in schedule loading

Currently, we are checking the reported scenario from our end. We will update you on the further details on January 18, 2023. We appreciate the patience until then.

Regards,

Karthick M.



SS SaiGanesh Sakthivel Syncfusion Team January 18, 2023 12:45 PM UTC

Hi Alban Favre,


#Regarding Custom Appointment template view causing delays in schedule loading

As of now, we do not have a workaround for the reported scenario. The reported issue occurs when converting from the forms view to the native view, which makes the conversion slow and affects the schedule control's appointment loading performance when using a custom view. We are currently tracking this issue with the Xamarin team. Please refer to the following link for more information:


Link: https://github.com/xamarin/Xamarin.Forms/issues/4371


Once we receive a solution from the Xamarin team, we will update you with further details. We apologize for the inconvenience and appreciate your patience in the meantime.

 

Regards,

SaiGanesh Sakthivel


Loader.
Up arrow icon