Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
Programmatically created appointments aren't fully functional.
posted

Hello,

I am using the xamSchedule control to display a list of appointments from a database based on which user has been selected. However, all of my programmatically created appointments come through on the calendar as white instead of the expected blue and they are unable to be dragged and manipulated. I assume that I am neglecting to bind something correctly or filling something incorrectly but I'm not sure where I'm going wrong. Here are my snippets and a screenshot:

XAML:

<ig:XamOutlookCalendarView Grid.Row="1" x:Name="outlookCalendarView" ShowWorkingHoursOnly="True" CurrentViewMode="{Binding ElementName=Data}" HeaderVisibility="Visible" CurrentViewModeChanged="outlookCalendarView_CurrentViewModeChanged" MouseDown="dayView_MouseDown" Grid.ColumnSpan="2">
                                <ig:XamOutlookCalendarView.DataManager>
                                    <ig:XamScheduleDataManager CurrentUserId="own1" x:Name="dataManager">
                                        <ig:XamScheduleDataManager.Settings>
                                            <ig:ScheduleSettings WorkDays="Monday, Tuesday, Wednesday, Thursday, Friday"  >
                                                <ig:ScheduleSettings.WorkingHours>
                                                    <ig:WorkingHoursCollection>
                                                        <ig:TimeRange Start="06:00" End="13:00" />
                                                        <ig:TimeRange Start="14:00" End="16:00" />
                                                    </ig:WorkingHoursCollection>
                                                </ig:ScheduleSettings.WorkingHours>
                                            </ig:ScheduleSettings>
                                        </ig:XamScheduleDataManager.Settings>
                                        <ig:XamScheduleDataManager.CalendarGroups>
                                            <ig:CalendarGroup InitialCalendarIds="own1"/>
                                            <ig:CalendarGroup InitialCalendarIds="own2"/>
                                        </ig:XamScheduleDataManager.CalendarGroups>
                                        <ig:XamScheduleDataManager.DataConnector>
                                            <ig:ListScheduleDataConnector
                                                ResourceItemsSource="{Binding Resources, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                                ResourceCalendarItemsSource="{Binding Calendars, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                                AppointmentItemsSource="{Binding Appointments, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                                        </ig:XamScheduleDataManager.DataConnector>
                                    </ig:XamScheduleDataManager>
                                </ig:XamOutlookCalendarView.DataManager>
                            </ig:XamOutlookCalendarView>

C#:

Resources.Add(new Resource
                {
                    Id = "own1",
                    Name = driver1.Name
                });

                ResourceCalendars.Add(new ResourceCalendar
                {
                    Id = "cal1",
                    OwningResourceId = "own1"
                });

 foreach (Journey jrny in jrnys)
                {
                    if (jrny.Template == false)
                    {
                        if (jrny.JourneyStatusId != (int)JourneyStatuses.Cancelled)
                        {
                            Appointment app = new Appointment();
                            app.Id = jrny.JourneyId.ToString() + "-" + calId;
                            app.OwningResourceId = "own1";
                            app.OwningCalendarId = "cal1";
                            app.Subject = jrny.Description;

                            app.DataItem = jrny;
                            if (jrny.Stops.Count > 0)
                            {
                                if (jrny.JourneyDate != null)
                                {
                                    app.Start = jrny.JourneyDate.Value.AddHours(jrny.Stops[0].ArrivalTime.Hours).AddMinutes(jrny.Stops[0].ArrivalTime.Minutes).ToUniversalTime();
                                    app.End = jrny.JourneyDate.Value.AddHours(jrny.Stops[0].ArrivalTime.Hours).AddMinutes(jrny.Stops[0].ArrivalTime.Minutes + jrny.Stops[0].WaitTime).ToUniversalTime();
                                }
                            }
                            calId++;
                            foreach (Stop stop in jrny.Stops)
                            {
                                if (stop.Passengers.Count > 0)
                                {
                                    //app.Location = app.Location + stop.Passengers[0].Address.PostCode + "; ";
                                    app.Location = app.Location + stop.StopType.StopTypeName + " ";
                                    foreach (TransportableItem trans in stop.Passengers)
                                    {
                                        app.Location = app.Location + trans.Name + " ";
                                    }
                                    app.Location = app.Location + stop.Passengers[0].Address.Line1 + ", " + stop.Passengers[0].Address.PostCode + " at " + stop.ArrivalTime.ToString();
                                    app.Location = app.Location + "." + System.Environment.NewLine;
                                }
                            }
                            Appointments.Add(app);
                        }
                    }
                }

Screenshot:

Appointment Problem

Parents Reply Children