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

AppointmentMapping does not allow subclasses

Hello, I have a class like this

public class Meeting
{
    public EventData Data{ get; set; }
    public string Title { get; set; }
}

public class EventData { public DateTime From { get; set; } public DateTime To { get; set; } public bool IsAllDay { get; set; } public TimeZoneInfo StartTimeZone { get; set; } public TimeZoneInfo EndTimeZone { get; set; } public Brush Background { get; set; } }


ObservableCollection<Meeting> Events {get;set;}


XAML is like

...


 <scheduler:SfScheduler x:Name="Scheduler" View="Week"

                           DisplayDate="{Binding DisplayDate}"
                            AppointmentsSource="{Binding Events}"
                           AllowedViews="Day,Week,WorkWeek,Month,TimelineDay,TimelineWeek,TimelineWorkWeek,TimelineMonth"
                           >
        <scheduler:SfScheduler.AppointmentMapping>
            <scheduler:SchedulerAppointmentMapping
                Subject="Title" <-- WORK
                StartTime="Data.From" <-- NOT WORK
                EndTime="Data.To" <-- NOT WORK
                IsAllDay="Data.IsAllDay"/> <-- NOT WORK
        </scheduler:SfScheduler.AppointmentMapping>

    </scheduler:SfScheduler>


Looks like the Mapping tools don't accept subclass.  

Your help is appreciated


Thanks




3 Replies

KA Karthikraja Arumugam Syncfusion Team January 26, 2023 08:38 AM UTC

Hi Alfonso,

#Regarding AppointmentMapping using a Subclass
According to the Scheduler's implementation, the appointment mapping only allows direct properties from the model class. To map sub-class property values from the model class, you need to create new properties and map the model properties to the Scheduler. Check the code snippet below for an example.

Code Snippet

    public class Meeting

    {

        public EventData Data { get; set; }

        public string Title { get; set; }

 

        public DateTime From

        {

            get

            {

                return this.Data.From;

            }

        }

 

        public DateTime To

        {

            get

            {

                return this.Data.To;

            }

        }

 

        public bool IsAllDay

        {

            get

            {

                return this.Data.IsAllDay;

            }

        }

 

        public Brush Background

        {

            get

            {

                return this.Data.Background;

            }

        }

    }

 

      <scheduler:SfScheduler x:Name="Scheduler" View="Week"

                            AppointmentsSource="{Binding Events}"

                            DisplayDate="{Binding DisplayDate}"

                          AllowedViews="Day,Week,WorkWeek,Month,TimelineDay,TimelineWeek,TimelineWorkWeek,TimelineMonth">

            <scheduler:SfScheduler.AppointmentMapping>

                <scheduler:SchedulerAppointmentMapping

                Subject="Title"

                StartTime="From"

                EndTime="To"

                IsAllDay="IsAllDay"/>

        </scheduler:SfScheduler.AppointmentMapping>

        </scheduler:SfScheduler>


Please let us know if you have any concerns.

Regards,

Karthik Raja A



AL Alfonso January 26, 2023 03:40 PM UTC

Hi Karthik 

Thank you for your quick response.

My workaround was very similar to your solutions, I do not like it, but it works!


Many thanks!

Alfonso



SS SaiGanesh Sakthivel Syncfusion Team January 27, 2023 08:48 AM UTC

Hi Alfonso,


We are glad to know that the provided solution is resolved the query. Please let us know if you need any further assistance.


Loader.
Live Chat Icon For mobile
Up arrow icon