I found the following article for mapping my datasource to the scheduler control.
I'm having the following problem.
I mapped every single property for the appointment collection [See code below] also In my model view I added collections for ResourceItems and Calendars and i instantiate them in my init method in my model view [See code below]. I added for my event items an OwningResourceId and an OwiningCalendarId that return the intance ids from my initialized method.
WWhen I run I keep getting the following error:
'Collection property 'Infragistics.Controls.Schedules.ListScheduleDataConnector'.'AppointmentPropertyMappings' is null.'
When I add an appointments class and a collection in my model view and dump my event values directly then everything works...my problem is that I have properties in my custom business object that i want to utilize to customize the scheduler data presenter template....I tried to add the fields i needed into the Appointment class and dump my needed field values so that I could use them when customizing the template but they don't seem to be picked up at all... how do i handle this problem?
var Apps2 = EventCollection.Select(r => new Appointment { Id = r.EventId.ToString(), Start = r.EventStartDate.GetValueOrDefault(Convert.ToDateTime(r.EventDate)), End = r.EventEndDate.GetValueOrDefault(Convert.ToDateTime(r.EventDate)), OwningCalendarId = "cal0", OwningResourceId = "res0", Subject = r.EventName, Description = r.EventNotes, IsTimeZoneNeutral = true, FightCount = r.FightCount, HasTitleFight = r.HasTitleFight }); foreach (var App in Apps2) Appointments.Add(App);
----------------------------------------------
MY XAML
___________________________
<ig:ListScheduleDataConnector AppointmentItemsSource="{Binding EventDataCardCollection}" ResourceItemsSource="{Binding ResourceItems}" ResourceCalendarItemsSource="{Binding Calendars}"> <ig:ListScheduleDataConnector.AppointmentPropertyMappings> <ig:AppointmentPropertyMapping AppointmentProperty="Id" DataObjectProperty="EventId" /> <ig:AppointmentPropertyMapping AppointmentProperty="Start" DataObjectProperty="EventStartDate" /> <ig:AppointmentPropertyMapping AppointmentProperty="End" DataObjectProperty="EventEndDate" /> <ig:AppointmentPropertyMapping AppointmentProperty="OwningResourceId" DataObjectProperty="OwningResourceId" /> <ig:AppointmentPropertyMapping AppointmentProperty="OwningCalendarId" DataObjectProperty="OwningCalendarId" /> <ig:AppointmentPropertyMapping AppointmentProperty="Subject" DataObjectProperty="EventName" /> <ig:AppointmentPropertyMapping AppointmentProperty="Description" DataObjectProperty="EventNotes" /> </ig:ListScheduleDataConnector.AppointmentPropertyMappings> <ig:ListScheduleDataConnector.ResourceCalendarPropertyMappings> <ig:ResourceCalendarPropertyMappingCollection UseDefaultMappings="True"></ig:ResourceCalendarPropertyMappingCollection> </ig:ListScheduleDataConnector.ResourceCalendarPropertyMappings> <ig:ListScheduleDataConnector.ResourcePropertyMappings> <ig:ResourcePropertyMappingCollection UseDefaultMappings="True"> </ig:ResourcePropertyMappingCollection> </ig:ListScheduleDataConnector.ResourcePropertyMappings> </ig:ListScheduleDataConnector>
_________________________________________________
MODEL VIEW
________________________________________________
public void Initialize() { ResourceItems = new ObservableCollection<Resource>(); ResourceItems.Add(new Resource() { Id = "res0" }); Calendars = new ObservableCollection<ResourceCalendar>(); Calendars.Add(new ResourceCalendar() { Id = "cal0", OwningResourceId = "res0" }); EventCollection = GoGetMyEventCollection();
}
http://help.infragistics.com/Help/NetAdvantage/WPF/2011.1/CLR4.0/html/xamSchedule_Using_Connector_Mapping.html
I found the problem. On our tables the appointment enddate is optional because we always default to startdate if endate is null. I created a custom variable to do this for me and binding to this instead and it worked. I wasn't getting any error messages regarding this, it was just not painting the appointments.
Hi,
There's no limit on number of items. Is anything different about the data structure - maybe column names?
Sandip
Is there such a thing as a Max collection size when doing custom mapping? I'm testing my changes in one server that has very few entries and all of my appointments showed.
When I switched to another server that is retrieving almost 4,000 entries no appointments get render...but if instead of trying to map my object collection I dump it into the built in Infragistics Appointment class object and create an appointment collection [dumping the same properties i had mapped through xaml for my custom collection] all of the appointments show.
Diyan was addressing your specific question about the exception. His response was correct. Basically since the mappings properties are get/set (in order to support binding) you have to set the property to an instance of the appropriate collection. I.e. you don't have the <ig:AppointmentPropertyMappingCollection> tags surrounding your <ig:AppointmentPropertyMapping> instances.
<ig:ListScheduleDataConnector.AppointmentPropertyMappings> <ig:AppointmentPropertyMappingCollection> <ig:AppointmentPropertyMapping /> </ig:AppointmentPropertyMappingCollection> </ig:ListScheduleDataConnector.AppointmentPropertyMappings></ig:ListScheduleDataConnector>
If the Rectangle in this reply is within the AppointmentPresenter and you wanted to access a property on the dataitem that the AppointmentPresenter represents then you could probably just bind with a path of Activity.DataItem.HasTitleFlight (without the relative source).
Sorry but this did not help me at all that's the same link i referenced in my question post.
What I'm trying to do to get around the fact that i cannot have my own custom variables to bind to and change the gui is the following.
I created the extra properties in the appointment class as described in my earlier post. I then proceeded to change the template for xamscheduler control to display a green box on my appointment entries in the calendar.
I succeeded adding the rectangle the only problem is that I don't want to display the green rectangle legend on all appointments only on some...that's why I need my custom properties.
so I changed my code to do the following
<Rectangle Name="TitleRec" Tag="{Binding Id}" Width="10" Height="10" ToolTip="This event has a title fight." Stroke="White" Fill="Green" Visibility="{Binding Path=DataContext.Appointments[1].HasTitleFight,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}},Converter={StaticResource boolToVisibility}}" HorizontalAlignment="Right"></Rectangle>
My problem is that I'm not sure how I can get the Id [From the Appointment.Id] to pass it in my bindings Binding Path=DataContext.Appointments[Id].HasTitleFight
Can this even be done? Help please!