Syncfusion的SfSchedule不处理不同的项目类型

时间:2017-08-18 03:57:45

标签: c# data-binding uwp syncfusion sfschedule

情境:我的UI中有Syncfusion SfSchedule控件。我将约会列表绑定到ItemsSource,如下所示:

<schedule:SfSchedule x:Name="MyCalendar"
                     ItemsSource="{Binding Appointments}"
                     ... />

我的Appointments属性是实现我编写的接口的对象列表:

private ObservableCollection<ICalendarItem> _appointments;
public ObservableCollection<ICalendarItem> Appointments
{
    get => _appointments;
    private set => Set(ref _appointments, value);
}

我有ICalendarItem的两个实现:SingleCalendarItemRepetitiveCalendarItem

问题:只要我的Appointments列表仅包含其中一种日历项类型,Syncfusion的日程控制就能完美运行并显示我的约会,例如SingleCalendarItem或仅RepetitiveCalendarItem

第二个我将两个对象类型添加到我的列表中,计划控件不显示任何内容。即使我绑定了另一个仅包含SingleCalendarItem类型对象的列表,它仍然不会显示任何内容。

问题:一旦绑定项目源是包含多种类型的列表,即使它们实现相同的接口,看起来Syncfusion SfSchedule控件也会出现打嗝。有人能够确认这是SfSchedule中的错误和/或知道如何绑定不同对象的解决方法吗?

1 个答案:

答案 0 :(得分:1)

我相当确定这是Syncfusion SfSchedule控件中的错误(截至2017年8月)。找到了一个解决方法:我构建了一个包含任何ICalendarItem对象的外观,并公开了它们的接口属性和方法:

public class CalendarItemFacade : ICalendarItem
{
    private ICalendarItem _calendarItem;
    public CalendarItemFacade(ICalendarItem calendarItem)
    {
        _calendarItem = calendarItem;
    }

    public DateTime StartTime => _calendarItem.StartTime;
    // All other interface implementations follow here
}

我没有为SfSchedule属性分配不同日历项类型的列表,而是确保它们都是我的外观类型CalendarItemFacade

更新:我向Syncfusion报告了这个错误:https://www.syncfusion.com/support/directtrac/incidents/185839。 Syncfusion确认了这个问题。自2017年4月14日以来,该错误已得到修复 - 需要进行测试。