我正在尝试使用Telerik RadTimeline获得简单的数据绑定。我几乎遵循this的观点,我拥有演示中的所有内容,但仍然无法再现任何结果。目标是创建与链接相同的输出。我对RadTimeline和WPF完全陌生。
基本上,我有一个约会对象,它具有“期间”字段。 Period具有startDate和endDate,它们是DateTime对象。目的是完全按照链接上的图片显示约会。
因此,在我的ScheduleView窗口中,(我将只写关键内容):
public ScheduleView(Institution selectedInstitution)
{
InitializeComponent();
this.selectedInstitution = selectedInstitution;
this.DataContext = new TestObject(//HERE IS LIST<Appointment);
}
TestObject
的字段Data
(当然具有属性)为List<Item>
,其名称与示例中的链接相同。
在TestObject
的构造函数中,发生这种情况:
public TestObject(List<Appointment> appointments)
{
List<Item> li = new List<Item>();
foreach(Appointment ap in appointments)
{
li.Add(new Item(ap.Period.Start.Subtract(ap.Period.End),ap.Period.Start));
}
this.data = li;
}
和Item对象:
public Item(TimeSpan timeSpan,DateTime startDate)
{
this.timeSpan = timeSpan;
this.startDate = startDate;
}
这是XAML:
<Grid>
<telerik:RadTimeline x:Name="telerikTimeline" Content="RadTimeline"
HorizontalAlignment="Left" Height="333" Margin="45,53,0" VerticalAlignment="Top" Width="689"
PeriodStart="05/01/2019 00:00:00"
PeriodEnd="05/28/2019 00:00:00"
StartPath="StartDate"
DurationPath="TimeSpan"
ItemsSource="{Binding Data}">
<telerik:RadTimeline.Intervals>
<telerik:Weekinterval />
<telerik:DayInterval />
</telerik:RadTimeline.Intervals>
</telerik:RadTimeline>
</Grid>
我想念什么?我在输出中看到了我在xaml中声明的所有内容,但没有看到沿时间轴伸展的Item
对象。