/// <summary> /// 设置TimelineItem的位置属性 /// </summary> /// <param name="index"></param> private void SetTimelineItem(int index) { if (index > this.Items.Count || index < 0) { return; } CollectionlineItem timelineItem = this.ItemContainerGenerator.ContainerFromIndex(index) as CollectionlineItem; if (timelineItem == null) { return; } ShowTitleItem(index); timelineItem.IsFirstItem = index == 0; timelineItem.IsLastItem = index == this.Items.Count - 1; timelineItem.IsMiddleItem = index > 0 && index < this.Items.Count - 1; }
protected override void PrepareContainerForItemOverride(DependencyObject element, object item) { int index = this.ItemContainerGenerator.IndexFromContainer(element); CollectionlineItem timelineItem = element as CollectionlineItem; if (timelineItem == null) { return; } if (index == 0) { timelineItem.IsFirstItem = true; } if (index == this.Items.Count - 1) { timelineItem.IsLastItem = true; } ShowTitleItem(index); base.PrepareContainerForItemOverride(timelineItem, item); }