开发者

UserControl as Content for HeaderedContentControl.HeaderTemplate

I have a UserControl that I have successfully been using as a header for presentations that involve a list which can be headered, using the xaml below:

<DockPanel >
    <uc:ListSubjectHeader Subject="{Binding DisplayName}" 
                          AddNewItemCommand="{Binding AddCommand}"
                           ImageSource="..."  />

<!-- other controls -->

</DockPanel>

I would like to use this same control in another presentation where it would be the content for the header in a HeaderedContentControl, and came up with this xaml to do that:

<HeaderedContentControl Content="{Binding Path=DetailViewDepartment}" >
    <HeaderedContentControl.HeaderTemplate>
        <DataTemplate  DataType="{x:Type vm:DepartmentSelectionViewModel}">
            <uc:ListSubjectHeader Subject="{Binding DisplayName}" ...  />

        </DataTemplate>
    </HeaderedContentControl.HeaderTemplate>
</HeaderedContentControl>

The visual elements show up the way I want them to, but data does not. I should note that I am using th开发者_开发问答e same view model (vm:DepartmentSelectionViewModel) in a different control's DataTemplate in the same presentation, which I asked as a different question here. If you know the answer to this one you likely know the answer to that one too.

How can I fix this?

Cheers,

Berryl


The HeaderTemplate applies to the object in the Header property, not Content. Content uses the ContentTemplate, just like in the normal ContentControl.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜