WPF 正在寻找使用文本标记框架创建边框的方法

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18068033/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 09:22:20  来源:igfitidea点击:

WPF looking for way to create border with text labeling the frame

c#wpfformsxaml

提问by James Joshua Street

Something like this

像这样的东西

enter image description here

在此处输入图片说明

was available in windows forms, but i forget what it was called. But I'm just looking for some good borders to outline regions that allows me to name the region.

在 Windows 窗体中可用,但我忘记它叫什么了。但我只是在寻找一些好的边界来勾勒出允许我命名该区域的区域。

回答by BlackWasp

Sounds like you need a GroupBox. I wrote an article about these but I won't post a link, as I don't like using StackOverflow for promoting web sites. I will post the opening example XAML though so you can see the effect and check if it's what you want.

听起来您需要一个 GroupBox。我写了一篇关于这些的文章,但我不会发布链接,因为我不喜欢使用 StackOverflow 来推广网站。不过,我将发布开场示例 XAML,这样您就可以看到效果并检查它是否是您想要的。

<Window x:Class="GroupBoxDemo.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="GroupBox Demo"
        Width="250"
        Height="180">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <GroupBox Header="Mouse Handedness">
            <StackPanel>
                <RadioButton Content="Left-Handed" Margin="5"/>
                <RadioButton Content="Right-Handed" Margin="5" IsChecked="True"/>
            </StackPanel>
        </GroupBox>

        <GroupBox Grid.Row="1" Header="Double Click Speed">
            <Slider Margin="5" />
        </GroupBox>
    </Grid>
</Window>

It looks like:

看起来像:

WPF Groupbox

WPF 分组框