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

Answers


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


Need Your Help

Using formulas within SUMIFS

excel excel-2007

I have a three column workbook with the following data:

run an R Markdown (check.Rmd ) and an R knitr (test.Rnw ) file together

r markdown knitr r-markdown

I have the following problem; There are 2 big documents, one written in R Markdown (check.Rmd ) and the other in R knitr (test.Rnw ). In the first doc we have a code like the following: