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
30
XamDayView: Custom dialog makes GMT Daylight Saving to be ignored.
posted

Hi there,

I am using XamDayView control in my MVVM application and I recently noticed that after the UK time changed on the 31st of March (UTC became UTC+01) the custom dialog I have created is still stuck on the old TimeZone. More specifically, the ActivityBase activity which is one of CreateActivityDialog method's parameters has the wrong Start property. For example I am double-clicking on a slot which starts at 10am and the Start of the activity is 09am, even though the appointment is inserted in the correct slot. It was working perfectly fine before the time change. I read your related article https://ko.infragistics.com/help/wpf/xamschedule-using-timezone-support and from what I understand the only fix would be to create a custom TimeZoneToken that will represent "British Summer Time" but it is not very clear to me how. I have created a quick demo and attached my code and some screenshots to demonstrate what the problem looks like. Let me know if something is not clear.

My ViewModel:

public class ScheduleInf
    {
        public ScheduleInf()
        {
            Initialize();
        }

        public Resource Person { get; set; } = new Resource { Id = "own1" };
        public ResourceCalendar Calendar { get; set; } = new ResourceCalendar { Id = "cal1", OwningResourceId = "own1" };
        public ObservableCollection<Appointment> Appointments { get; set; } = new ObservableCollection<Appointment>();
        public ListScheduleDataConnector DataConnector { get; set; }
        public XamScheduleDataManager DataManager { get; set; }
        public CalendarGroupCollection CalendarGroups { get; set; }

        public void Initialize()
        {
            DataConnector = new ListScheduleDataConnector
            {
                ResourceItemsSource = new ObservableCollection<Resource> { Person },
                ResourceCalendarItemsSource = new ObservableCollection<ResourceCalendar> { Calendar },
                AppointmentItemsSource = Appointments,
                AppointmentPropertyMappings = new AppointmentPropertyMappingCollection() { UseDefaultMappings = true }               
            };
            DataManager = new XamScheduleDataManager { DataConnector = DataConnector, DialogFactory = new CustomScheduleDialog()};
            CalendarGroups = DataManager.CalendarGroups;
            CalendarGroups.Add(new CalendarGroup { InitialCalendarIds = string.Concat("own1", "[cal1]") });
        }
    }

My Custom Dialog class:

 public class CustomScheduleDialog : ScheduleDialogFactoryBase
    {
        public override ActivityTypes SupportedActivityDialogTypes => ActivityTypes.Appointment;

        public override FrameworkElement CreateActivityDialog(FrameworkElement container, XamScheduleDataManager dataManager, ActivityBase activity, bool allowModifications, bool allowRemove)
        {
            if (activity.ActivityType != ActivityType.Appointment) return null;

            return new Window()
            {
                Content = new TextBlock { Text = activity.Start.ToString(CultureInfo.CurrentCulture) }
            };
        }
    }

My Xaml:

 <Grid DataContext="{StaticResource Data}">
        <Grid DataContext="{Binding Inf}">
            <ig:XamDayView DataManager="{Binding DataManager}"/>
        </Grid>
    </Grid>

Thank you in advance for your time,

Christos