A common scenario in providing the xamScheduleDataManager with data is that the scheduling data is stored in a database or in custom objects. The ListScheduleDataConnector exposes several ItemsSource properties (e.g., AppointmentItemsSource) that can be set to any IEnumerable object that will provide the schedule data for that collection. The ListScheduleDataConnector makes use of LINQ to query the data source. If the data source is IQueryable then LINQ is used to retrieve only the activities needed for the current display.
In order to map the properties from the data source objects to the xamSchedule entities that will be created, the associated PropertyMappings collection should be provided (e.g., AppointmentPropertyMappings). These are collections of PropertyMapping objects (e.g., AppointmentPropertyMapping) that specify the name of the property on the data source object (via the DataObjectProperty), the name of the xamSchedule entity property that it corresponds to (e.g., using the AppointmentProperty), and optionally a Converter that can be used to convert between the datasource object’s property value and the xamSchedule property value. The following is an example of using these mapping properties:
Note: Property mapping collection has a UseDefaultMappings property. If the names of the properties of the data source object are the same as the names of the properties of the xamSchedule entity object, this property can be set to true to automatically map the properties. Reflection is used to find properties with the same names and any matching properties are automatically mapped. Furthermore, if the names of some properties are not the same, explicit property mapping entries for those properties can be added to the collection.
<ig:ListScheduleDataConnector x:Name="scheduleDataConnector"
ResourceItemsSource="{Binding CustomResources}"
ResourceCalendarItemsSource="{Binding CustomCalendars}"
AppointmentItemsSource="{Binding CustomAppointments}">
<ig:ListScheduleDataConnector.ResourcePropertyMappings>
<ig:ResourcePropertyMappingCollection>
<ig:ResourcePropertyMapping ResourceProperty="Id"
DataObjectProperty="MyId" />
<ig:ResourcePropertyMapping ResourceProperty="Name"
DataObjectProperty="MyName" />
</ig:ResourcePropertyMappingCollection>
</ig:ListScheduleDataConnector.ResourcePropertyMappings>
<ig:ListScheduleDataConnector.ResourceCalendarPropertyMappings>
<ig:ResourceCalendarPropertyMappingCollection>
<ig:ResourceCalendarPropertyMapping
ResourceCalendarProperty="Id"
DataObjectProperty="MyId" />
<ig:ResourceCalendarPropertyMapping
ResourceCalendarProperty="Name"
DataObjectProperty="MyName" />
<ig:ResourceCalendarPropertyMapping
ResourceCalendarProperty="OwningResourceId"
DataObjectProperty="MyResourceId" />
</ig:ResourceCalendarPropertyMappingCollection>
</ig:ListScheduleDataConnector.ResourceCalendarPropertyMappings>
<ig:ListScheduleDataConnector.AppointmentPropertyMappings>
<ig:AppointmentPropertyMappingCollection>
<ig:AppointmentPropertyMapping
AppointmentProperty="Id"
DataObjectProperty="MyId" />
<ig:AppointmentPropertyMapping
AppointmentProperty="Start"
DataObjectProperty="MyStart" />
<ig:AppointmentPropertyMapping
AppointmentProperty="End"
DataObjectProperty="MyEnd" />
<ig:AppointmentPropertyMapping
AppointmentProperty="OwningResourceId"
DataObjectProperty="MyOwnerId" />
<ig:AppointmentPropertyMapping
AppointmentProperty="OwningCalendarId"
DataObjectProperty="MyCalendarId" />
<ig:AppointmentPropertyMapping
AppointmentProperty="Subject"
DataObjectProperty="MySubject" />
<ig:AppointmentPropertyMapping
AppointmentProperty="Description"
DataObjectProperty="MyDescription" />
</ig:AppointmentPropertyMappingCollection>
</ig:ListScheduleDataConnector.AppointmentPropertyMappings>
</ig:ListScheduleDataConnector>
dataConnector.ResourcePropertyMappings =_
New ResourcePropertyMappingCollection()
dataConnector.ResourcePropertyMappings._
Add(ResourceProperty.Id, "MyId")
dataConnector.ResourcePropertyMappings._
Add(ResourceProperty.Name, "MyName")
dataConnector.ResourceCalendarPropertyMappings =_
New ResourceCalendarPropertyMappingCollection()
dataConnector.ResourceCalendarPropertyMappings._
Add(ResourceCalendarProperty.Id, "MyId")
dataConnector.ResourceCalendarPropertyMappings._
Add(ResourceCalendarProperty.Name, "MyName")
dataConnector.ResourceCalendarPropertyMappings._
Add(ResourceCalendarProperty.OwningResourceId, "MyResourceId")
dataConnector.AppointmentPropertyMappings =_
New AppointmentPropertyMappingCollection()
dataConnector.AppointmentPropertyMappings._
Add(AppointmentProperty.Id, "MyId")
dataConnector.AppointmentPropertyMappings._
Add(AppointmentProperty.Start, "MyStart")
dataConnector.AppointmentPropertyMappings._
Add(AppointmentProperty.[End], "MyEnd")
dataConnector.AppointmentPropertyMappings._
Add(AppointmentProperty.OwningResourceId, "MyOwnerId")
dataConnector.AppointmentPropertyMappings._
Add(AppointmentProperty.OwningCalendarId, "MyCalendarId")
dataConnector.AppointmentPropertyMappings._
Add(AppointmentProperty.Subject, "MySubject")
dataConnector.AppointmentPropertyMappings._
Add(AppointmentProperty.Description, "MyDescription")
dataConnector.ResourcePropertyMappings =
new ResourcePropertyMappingCollection();
dataConnector.ResourcePropertyMappings.Add(
ResourceProperty.Id, "MyId");
dataConnector.ResourcePropertyMappings.Add(
ResourceProperty.Name, "MyName");
dataConnector.ResourceCalendarPropertyMappings =
new ResourceCalendarPropertyMappingCollection();
dataConnector.ResourceCalendarPropertyMappings.Add(
ResourceCalendarProperty.Id, "MyId");
dataConnector.ResourceCalendarPropertyMappings.Add(
ResourceCalendarProperty.Name, "MyName");
dataConnector.ResourceCalendarPropertyMappings.Add(
ResourceCalendarProperty.OwningResourceId, "MyResourceId");
dataConnector.AppointmentPropertyMappings =
new AppointmentPropertyMappingCollection();
dataConnector.AppointmentPropertyMappings.Add(
AppointmentProperty.Id, "MyId");
dataConnector.AppointmentPropertyMappings.Add(
AppointmentProperty.Start, "MyStart");
dataConnector.AppointmentPropertyMappings.Add(
AppointmentProperty.End, "MyEnd");
dataConnector.AppointmentPropertyMappings.Add(
AppointmentProperty.OwningResourceId, "MyOwnerId");
dataConnector.AppointmentPropertyMappings.Add(
AppointmentProperty.OwningCalendarId, "MyCalendarId");
dataConnector.AppointmentPropertyMappings.Add(
AppointmentProperty.Subject, "MySubject");
dataConnector.AppointmentPropertyMappings.Add(
AppointmentProperty.Description, "MyDescription");
In the sample code above the custom collections (CustomResources, CustomCalendars and CustomAppointments) are IEnumerable, and MyId, MyName, etc. are the names of the properties of the custom types that these collections contain.
Certain property mappings are required for proper functioning of the XamSchedule. Id field is one of them; and furthermore, the Id values have to be unique to each object in an items source.