代码之家  ›  专栏  ›  技术社区  ›  Steve

WPF-标题边框

  •  16
  • Steve  · 技术社区  · 14 年前

    WPF中是否有一个等价于Java的Swing框架中的标题边框?下面是一个链接,其中包含了我正在寻找的截图,以及一些非常糟糕的ASCII艺术。

    http://www.java2s.com/Code/Java/Swing-JFC/TitledBorder.htm

    -------TITLE--------
    |                  |
    |                  | 
    |                  |
    |__________________|
    

    2 回复  |  直到 14 年前
        1
  •  38
  •   ChrisF    14 年前

    你所追求的在WindowsSpeak中被称为“GroupBox”。

    this example 如何在C#角使用:

    <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只能包含一个直接子控件,因此如果需要多个子控件,则必须将它们包装在网格或StackPanel中。

    在MSDN上有更多关于GroupBox的信息 Class Page How to Style it

        2
  •  4
  •   Tim Lloyd    14 年前

    在WPF中,这将是一个GroupBox,它位于具有边框和标题的容器控件中。

    http://msdn.microsoft.com/en-us/library/system.windows.controls.groupbox.aspx

    此处,GroupBox的标题为“Employee Data”,并包含其他控件。

    http://i.msdn.microsoft.com/dynimg/IC79468.jpg