Class SfScheduler
Represents the control which allows the user to create and manage appointments.
Inheritance
System.Object
SfScheduler
Implements
System.IDisposable
Namespace: Syncfusion.UI.Xaml.Scheduler
Assembly: Syncfusion.SfSchedule.XForms.WPF.dll
Syntax
public class SfScheduler : Control, IDisposable
Examples
Below example shows, how to bind ItemsSource
and populate appointments with resources in Scheduler control.
public class SchedulerModel : NotificationObject
{
private DateTime from, to;
private string eventName;
private bool isAllDay;
private string startTimeZone, endTimeZone;
private Brush color;
private ObservableCollection<DateTime> recurrenceExceptionDates = new ObservableCollection<DateTime>();
private string rRUle;
private object recurrenceId;
private object id;
private ObservableCollection<object> resources;
private string notes;
public DateTime From
{
get { return from; }
set
{
from = value;
RaisePropertyChanged("From");
}
}
public DateTime To
{
get { return to; }
set
{
to = value;
RaisePropertyChanged("To");
}
}
public bool IsAllDay
{
get { return isAllDay; }
set
{
isAllDay = value;
RaisePropertyChanged("IsAllDay");
}
}
public string EventName
{
get { return eventName; }
set
{
eventName = value;
RaisePropertyChanged("EventName");
}
}
public string Notes
{
get { return notes; }
set
{
notes = value;
RaisePropertyChanged("Notes");
}
}
public string StartTimeZone
{
get { return startTimeZone; }
set
{
startTimeZone = value;
RaisePropertyChanged("StartTimeZone");
}
}
public string EndTimeZone
{
get { return endTimeZone; }
set
{
endTimeZone = value;
RaisePropertyChanged("EndTimeZone");
}
}
public Brush Color
{
get { return color; }
set
{
color = value;
RaisePropertyChanged("Color");
}
}
public object RecurrenceId
{
get { return recurrenceId; }
set
{
recurrenceId = value;
RaisePropertyChanged("RecurrenceId");
}
}
public object Id
{
get { return id; }
set
{
id = value;
RaisePropertyChanged("Id");
}
}
public string RecurrenceRule
{
get { return rRUle; }
set
{
rRUle = value;
RaisePropertyChanged("RecurrenceRule");
}
}
public ObservableCollection<DateTime> RecurrenceExceptions
{
get { return recurrenceExceptionDates; }
set
{
recurrenceExceptionDates = value;
RaisePropertyChanged("RecurrenceExceptions");
}
}
public ObservableCollection<object> Resources
{
get { return resources; }
set
{
resources = value;
this.RaisePropertyChanged("Resources");
}
}
}
public class Employee
{
public string Name { get; set; }
public object ID { get; set; }
public Brush BackgroundBrush { get; set; }
public Brush ForegroundBrush { get; set; }
}
# [ViewModel.cs](#tab/tabid-2)
public class SchedulerViewModel : NotificationObject
{
private List<string> currentDayMeetings;
private List<Brush> colorCollection;
private ObservableCollection<object> resources;
private List<string> nameCollection;
public BindingViewModel()
{
this.InitializeDataForBookings();
this.InitializeResources();
this.BookingResourceAppointments();
}
public ObservableCollection<SchedulerModel> ResourceAppointments { get; set; }
public ObservableCollection<object> Resources
{
get { return resources; }
set
{
resources = value;
this.RaisePropertyChanged("Resources");
}
}
private void InitializeResources()
{
Random random = new Random();
this.Resources = new ObservableCollection<object>();
this.nameCollection = new List<string>();
this.nameCollection.Add("Sophia");
this.nameCollection.Add("Kinsley Elena");
this.nameCollection.Add("Adeline Ruby");
this.nameCollection.Add("Kinsley Ruby");
this.nameCollection.Add("Emilia");
this.nameCollection.Add("Daniel");
this.nameCollection.Add("Adeline Elena");
this.nameCollection.Add("Emilia William");
this.nameCollection.Add("James William");
this.nameCollection.Add("Zoey Addison");
this.nameCollection.Add("Danial William");
this.nameCollection.Add("Stephen Addison");
this.nameCollection.Add("Stephen");
this.nameCollection.Add("Danial Addison");
this.nameCollection.Add("Brooklyn");
for (int i = 0; i < 7; i++)
{
Employee employee = new Employee();
employee.Name = nameCollection[i];
employee.BackgroundBrush = this.colorCollection[random.Next(8)];
employee.ID = i.ToString();
Resources.Add(employee);
}
}
private void BookingResourceAppointments()
{
Random randomTime = new Random();
List<Point> randomTimeCollection = this.GettingTimeRanges();
ResourceAppointments = new ObservableCollection<SchedulerModel>();
DateTime date;
DateTime dateFrom = DateTime.Now.AddDays(-80);
DateTime dateTo = DateTime.Now.AddDays(80);
DateTime dateRangeStart = DateTime.Now.AddDays(-70);
DateTime dateRangeEnd = DateTime.Now.AddDays(70);
for (date = dateFrom; date < dateTo; date = date.AddDays(1))
{
if ((DateTime.Compare(date, dateRangeStart) > 0) && (DateTime.Compare(date, dateRangeEnd) < 0))
{
for (int additionalAppointmentIndex = 0; additionalAppointmentIndex < 8; additionalAppointmentIndex++)
{
SchedulerModel meeting = new SchedulerModel();
meeting.From = new DateTime(date.Year, date.Month, date.Day, randomTime.Next(0, 23), 0, 0);
meeting.To = meeting.From.AddHours(randomTime.Next(1, 3));
meeting.EventName = this.currentDayMeetings[randomTime.Next(9)];
meeting.Color = this.colorCollection[randomTime.Next(8)];
meeting.IsAllDay = false;
var coll = new ObservableCollection<object>
{
(resources[randomTime.Next(Resources.Count)] as Employee).ID
};
meeting.Resources = coll;
this.ResourceAppointments.Add(meeting);
}
}
else
{
SchedulerModel meeting = new SchedulerModel();
meeting.From = new DateTime(date.Year, date.Month, date.Day, randomTime.Next(0, 23), 0, 0);
meeting.To = meeting.From.AddDays(2).AddHours(1);
meeting.EventName = this.currentDayMeetings[randomTime.Next(9)];
meeting.Color = this.colorCollection[randomTime.Next(8)];
meeting.IsAllDay = true;
var coll = new ObservableCollection<object>
{
(resources[randomTime.Next(Resources.Count)] as Employee).ID
};
meeting.Resources = coll;
this.ResourceAppointments.Add(meeting);
}
}
}
private List<Point> GettingTimeRanges()
{
List<Point> randomTimeCollection = new List<Point>();
randomTimeCollection.Add(new Point(9, 11));
randomTimeCollection.Add(new Point(12, 14));
randomTimeCollection.Add(new Point(15, 17));
return randomTimeCollection;
}
private void InitializeDataForBookings()
{
this.currentDayMeetings = new List<string>();
this.currentDayMeetings.Add("General Meeting");
this.currentDayMeetings.Add("Plan Execution");
this.currentDayMeetings.Add("Project Plan");
this.currentDayMeetings.Add("Consulting");
this.currentDayMeetings.Add("Performance Check");
this.currentDayMeetings.Add("Yoga Therapy");
this.currentDayMeetings.Add("Plan Execution");
this.currentDayMeetings.Add("Project Plan");
this.currentDayMeetings.Add("Consulting");
this.currentDayMeetings.Add("Performance Check");
this.colorCollection = new List<Brush>();
this.colorCollection.Add(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF339933")));
this.colorCollection.Add(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF00ABA9")));
this.colorCollection.Add(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFE671B8")));
this.colorCollection.Add(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF1BA1E2")));
this.colorCollection.Add(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFD80073")));
this.colorCollection.Add(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFA2C139")));
this.colorCollection.Add(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFA2C139")));
this.colorCollection.Add(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFD80073")));
this.colorCollection.Add(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF339933")));
this.colorCollection.Add(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFE671B8")));
this.colorCollection.Add(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF00ABA9")));
}
}
# [MainWindow](#tab/tabid-3)
<syncfusion:SfScheduler ViewType = "Week"
ResourceGroupType="Resource"
ResourceCollection="{Binding Resources}"
ItemsSource="{Binding ResourceAppointments}">
<syncfusion:SfScheduler.ResourceMapping>
<syncfusion:ResourceMapping
Id = "ID"
Name="Name"
Background="BackgroundBrush"
Foreground="ForegroundBrush"/>
</syncfusion:SfScheduler.ResourceMapping>
<syncfusion:SfScheduler.AppointmentMapping>
<syncfusion:AppointmentMapping
Subject = "EventName"
StartTime="From"
EndTime="To"
AppointmentBackground="Color"
ResourceIdCollection ="Resources"
IsAllDay="IsAllDay"
RecurrenceExceptionDates="RecurrenceExceptions"
RecurrenceRule="RecurrenceRule"
RecurrenceId="RecurrenceId"/>
</syncfusion:SfScheduler.AppointmentMapping>
</syncfusion:SfScheduler>
Constructors
SfScheduler()
Initializes a new instance of the SfScheduler class.
Declaration
public SfScheduler()
Methods
Dispose()
Disposes all the resources used by the SfScheduler class.
Declaration
public void Dispose()
Dispose(Boolean)
Disposes all the resources used by the SfScheduler class.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | Indicates whether the call is from Dispose method or from a System.GC.SuppressFinalize(System.Object). |
MeasureOverride(Size)
Called to determine the size requirements for this panel and all of its children.
Declaration
protected override Size MeasureOverride(Size availableSize)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Size | availableSize | The available size that this object can give to child objects. |
Returns
Type | Description |
---|---|
System.Windows.Size | The available size. |
OnApplyTemplate()
Override Method to apply the template.
Declaration
public override void OnApplyTemplate()
OnPreviewKeyDown(KeyEventArgs)
Method to handle key board interaction with schedule day cells.
Declaration
protected override void OnPreviewKeyDown(KeyEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Input.KeyEventArgs | e | The pressed key arguments. |
Implements
System.IDisposable