您所追求的在 Windows 中称为“GroupBox”。
我已经找到了this example 如何在 C# Corner 上使用它:
<Window x:Class="GroupBoxSample.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<GroupBox Margin="10,10,10,10" FontSize="16" FontWeight="Bold"
Background="LightGray">
<GroupBox.Header>
Mindcracker Network
</GroupBox.Header>
<TextBlock FontSize="12" FontWeight="Regular">
This is a group box control content.
</TextBlock>
</GroupBox>
</Grid>
</Window>
一个 GroupBox 只能包含一个直接子控件,因此如果您想要多个子控件,您必须将它们包装在一个 Grid、一个 Panel 或一个 ContentControl 中。
在 MSDN 上有更多关于 GroupBox 的信息,它是 Class Page 和 How to Style it。
如果您希望标题文本不是左对齐,那么您需要创建自己的样式(如this answer 中所述。