views:

15

answers:

1

Hello

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 the 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

A: 

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

John Bowen
Hi John, and thanks for the reply. It is the content of the HeaderProperty I want to set. The content for the HeaderContentControl is already successfully occupied. Is there some other property of the Header (ie, not HeaderTemplate) that I need?
Berryl
I'm not sure what you're asking. The value you assign to the Header property of HeaderedContentControl is displayed using the HeaderTemplate in the same way that the Content is displayed with the ContentTemplate. You need to change Content="..." to Header="...".
John Bowen