Scheduler Components and Controls > Binding C1Scheduler using Silverlight > Binding AppointmentStorage to a Collection of Custom Business Objects |
C# |
Copy Code
|
---|---|
// Business object should implement INotifyPropertyChanged interface. public class AppointmentBORow : INotifyPropertyChanged { public AppointmentBORow(); public string Subject { get; set; } public DateTime Start { get; set; } public DateTime End { get; set; } public string Body { get; set; } public string Location { get; set; } public string Properties { get; set; } public Guid Id { get; set; } public bool IsDeleted { get; set; } public event PropertyChangedEventHandler PropertyChanged; } |
C# |
Copy Code
|
---|---|
// Business objects collection should implement // INotifyCollectionChanged interface. public class AppointmentBOList : ObservableCollection<AppointmentBORow> { } |
C# |
Copy Code
|
---|---|
public class AppointmentsBO { AppointmentBOList _list = new AppointmentBOList(); public AppointmentsBO(){ } public AppointmentBOList Appointments { get { return _list; } set { _list = value; } } } |
XAML |
Copy Code
|
---|---|
<UserControl xmlns:c1sched="clr-namespace:C1.Silverlight.Schedule;assembly=C1.Silverlight.Schedule" x:Class="C1Scheduler_BusinessObjectsBinding.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:c1="clr-namespace:C1.Silverlight;assembly=C1.Silverlight" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:C1Scheduler_BusinessObjectsBinding" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Loaded="UserControl_Loaded" mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480" FontFamily="Segoe UI"> <UserControl.Resources> <!-- Create instance of custom class keeping collection of business objects. --> <local:AppointmentsBO x:Key="_ds" /> </UserControl.Resources> |
XAML |
Copy Code
|
---|---|
<c1sched:C1Scheduler x:Name="sched1" > <!-- Map AppointmentStorage to collection of business objects --> <c1sched:NestedPropertySetter PropertyName="DataStorage.AppointmentStorage.Mappings.AppointmentProperties.MappingName" Value="Properties"/> <c1sched:NestedPropertySetter PropertyName="DataStorage.AppointmentStorage.Mappings.Body.MappingName" Value="Body"/> <c1sched:NestedPropertySetter PropertyName="DataStorage.AppointmentStorage.Mappings.End.MappingName" Value="End"/> <c1sched: PropertyName="DataStorage.AppointmentStorage.Mappings.IdMapping.MappingName" Value="Id"/> <c1sched: PropertyName="DataStorage.AppointmentStorage.Mappings.Location.MappingName" Value="Location"/> <c1sched: PropertyName="DataStorage.AppointmentStorage.Mappings.Start.MappingName" Value="Start"/> <c1sched: PropertyName="DataStorage.AppointmentStorage.Mappings.Subject.MappingName" Value="Subject"/> <c1sched:NestedPropertySetter PropertyName="DataStorage.AppointmentStorage.DataSource" Value="{Binding Path=Appointments, Mode=TwoWay, Source={StaticResource _ds}}" /> </c1sched:C1Scheduler> |
That’s all you need to do. At run time, any change to the AppointmentBOList will be reflected in C1Scheduler and vice versa.