UserControl作为HeaderedContentControl.HeaderTemplate的内容 [英] UserControl as Content for HeaderedContentControl.HeaderTemplate
问题描述
我有一个UserControl,我已经成功使用它作为演示文稿的标题,该演示文稿涉及可以使用以下xaml进行标题化的列表:
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>
我想在另一个演示文稿中使用相同的控件,它将作为标题中的内容一个HeaderedContentControl,并想出了这个xaml:
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>
视觉元素显示了我想要它们的方式,但数据却没有。我应该注意,我在同一演示文稿中的不同控件的DataTemplate中使用了相同的视图模型(vm:DepartmentSelectionViewModel),我将其作为不同的问题此处。如果您知道该答案,那么您也可能也知道该答案。
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.
我该如何解决?
干杯,
Berryl
Cheers,
Berryl
推荐答案
HeaderTemplate适用于Header属性中的对象,不满意。内容使用ContentTemplate,就像在普通的ContentControl中一样。
The HeaderTemplate applies to the object in the Header property, not Content. Content uses the ContentTemplate, just like in the normal ContentControl.
这篇关于UserControl作为HeaderedContentControl.HeaderTemplate的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!