Situation:我在UI中获得了同步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实现:SingleCalendarItem和RepetitiveCalendarItem。
Problem:Syncfusion的调度控制工作得很好,只要我的Appointments列表只包含日历项类型之一,例如只包含SingleCalendarItem或RepetitiveCalendarItem,就会显示我的约会。
当我将这两种对象类型添加到我的列表中时,调度控件将不会显示任何内容。即使我绑定了另一个仅由SingleCalendarItem类型的对象组成的列表,它也不会显示任何内容。
问题:当绑定项源是由多个类型组成的列表时,Syncfusion SfSchedule控件就会遇到麻烦,尽管它们实现了相同的接口。是否有人能够确认这是SfSchedule中的一个bug和/或知道如何绑定不同的对象?
发布于 2017-08-23 20:21:39
我相当肯定,这是一个bug在同步融合的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属性,而是确保它们都是我的facade类型的CalendarItemFacade。
更新:我向Syncfusion:https://www.syncfusion.com/support/directtrac/incidents/185839报告了这个bug。Syncfusion证实了这个问题。这个错误从2017年9月14日开始就被修复了--显然是要被测试的。
https://stackoverflow.com/questions/45748307
复制相似问题