2

次のことができるカスタム パネルを作成しました。

<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);
}

これを修正するにはどうすればよいですか?

4

1 に答える 1

3

ItemTemplatesそのコンテナItemsControlsContentPresenter. ItemsControl.ItemContainerStyleいずれにせよ、コンテナにプロパティを設定するにプロパティをバインドする必要があるでしょう。

于 2012-06-08T18:17:25.613 に答える