我创建了一个自定义面板,您可以使用它执行以下操作:
<custom:Timeline>
<Button custom:Timeline.PointInTime="6:30 PM" />
</custom:Timeline>
当我这样做时,它的效果非常好。但是,当我做这样的事情时(这是我需要做的):
<DataTemplate x:Key="TimelineItemTemplate">
<Grid d:DesignWidth="169" custom:Timeline.PointInTime="{Binding NotifyTime}">
</Grid>
</DataTemplate>
<ItemsControl Grid.RowSpan="2" ItemTemplate="{DynamicResource TimelineItemTemplate}" ItemsSource="{Binding Items}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<custom:Timeline/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
集合中的控件上未设置 PointInTime 附加属性InternalChildren
:
protected override Size ArrangeOverride(Size a_arrangeBounds)
{
foreach (UIElement uiChild in InternalChildren)
{
var pointInTime = GetPointInTime(uiChild);
// Arranginess stuff
// Timeline.PointInTimeProperty is not set on 'uiChild'. WTH?
}
return base.ArrangeOverride(a_arrangeBounds);
}
我该如何解决?