13

我正在开发 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>

请解释它并解释内容模板的作用。

4

1 回答 1

17

AHeaderedContentControl是一个显示其他控件的控件,但也为此提供了一个标题(如一个GroupBox或窗口标题)。

绑定到一组数据——在本HeaderedContentControl例中为“CurrentWorkspace”。

ContentTemplate描述了应该如何显示该数据。在这种特殊情况下,它是一种称为“WorkspaceTemplate”的东西,它将被定义为项目中某处的静态资源——要么在资源 XAML 文件中,要么在您的窗口中,在<Window.Resources>XAML 的顶部下方。

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

于 2012-05-16T03:21:22.050 回答