在wpf中使用HeaderedContentControl有什么用?

prj*_*dhi 12 wpf xaml

我正在研究WPF,但UI已针对古吉拉特语进行了本地化.在我的window.xaml中,我有2行2列.

我无法使用HeaderedContentControl标记.代码在这里:

<Border
            Grid.Row="1" Grid.Column="1"
            Style="{StaticResource MainBorderStyle}"
            Padding="0"
            BorderThickness="0,0,0,1"
            Background="#f9f9f9">
            <HeaderedContentControl
                VerticalContentAlignment="Stretch"
                Content="{Binding Path=CurrentWorkspace}"
                Style="{StaticResource MainWorkspaceStyle}"
                ContentTemplate="{StaticResource WorkspaceTemplate}"/>
        </Border>
Run Code Online (Sandbox Code Playgroud)

请解释一下,并解释内容模板的作用.

Rob*_*cus 16

A HeaderedContentControl是一个显示其他控件的控件,但也提供了一个标题(如GroupBox窗口标题或窗口标题).

HeaderedContentControl势必在这种情况下,"CurrentWorkspace"一组数据- .

ContentTemplate描述了数据的显示方式.在这种特殊情况下,它被称为"WorkspaceTemplate",它将被定义为项目中某处的静态资源 - 在资源XAML文件中,或者在窗口中,在<Window.Resources>XAML的顶部.

无论它在哪里,如果您搜索整个解决方案,WorkspaceTemplate最终应该看到它的定义.

  • 添加一个已经很好的答案:另一个HeaderedContentControl示例是TabControl中的标签页.除了显示一些内容之外,您还可以在标签的标题中添加任何内容(通常是字符串和小图形). (2认同)