Skip to content

Latest commit

 

History

History
89 lines (78 loc) · 2.84 KB

File metadata and controls

89 lines (78 loc) · 2.84 KB

How to enable drag and drop for custom appointments in Xamarin.Android Schedule(SfSchedule)

You can enable drag and drop for custom appointments in SfSchedule by implementing the INotifyPropertyChanged for your event.

Implements the INotifyPropertyChanged in custom appointment class and raise property changed notifier for all the properties used for appointment mapping.

public class Meeting : INotifyPropertyChanged
{
        private string eventname;
        private Calendar from;
        private Calendar to;
        private bool isAllDay;
        private int color;
 
        public string EventName
        {
            get { return eventname; }
            set
            {
                eventname = value;
                this.RaisePropertyChanged("EventName");
            }
        }
 
        public Calendar From
        {
            get { return from; }
            set
            {
                from = value;
                this.RaisePropertyChanged("From");
            }
        }
 
        public Calendar To
        {
            get { return to; }
            set
            {
                to = value;
                this.RaisePropertyChanged("To");
            }
        }
 
        public bool IsAllDay
        {
            get { return isAllDay; }
            set
            {
                isAllDay = value;
                this.RaisePropertyChanged("IsAllDay");
            }
        }
 
        public int Color
        {
            get { return color; }
            set
            {
                color = value;
                this.RaisePropertyChanged("Color");
            }
        }
 
        public event PropertyChangedEventHandler PropertyChanged;
 
        private void RaisePropertyChanged(String property)
        {
            if (this.PropertyChanged != null)
                this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs(property));
        }  
}

Enable appointment drag and drop support in schedule using AllowAppointmentDrag property of Schedule.

schedule.AllowAppointmentDrag = true;

Map the custom appointment properties with the SfSchedule using AppointmentMapping.

AppointmentMapping dataMapping = new AppointmentMapping();
dataMapping.Subject = "EventName";
dataMapping.StartTime = "From";
dataMapping.EndTime = "To";
dataMapping.Color = "Color";
dataMapping.IsAllDay = "IsAllDay";
schedule.AppointmentMapping = dataMapping;