none
GroupBox Border in WPF

    Question

  • Hi,

    I have a GroupBox.I Created the GroupBox as follows.

     

     <GroupBox Header="Search"  BorderThickness="2" BorderBrush="Black" Margin="0,2,0,0" Padding="0,1,0,0">

    ...................................................................

    </GroupBox>

    My problem is when i Run the application the GroupBox Border Line is in ZigZag (or) cutting Edges.The Bottom Border Line view is correct.The top Border Line is in cutting edges....How to solve this...


    PS.Shakeer Hussain
    Friday, February 11, 2011 10:37 AM

Answers

  • I just tried with the following xaml:

    <Window x:Class="WpfGroupBox.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
    <GroupBox Header="Search" BorderThickness="2" BorderBrush="Black" Margin="0,2,0,0" Padding="0,1,0,0">
    <StackPanel>
    <Button Content="Button" Height="50" Name="button1" Width="Auto" />
    <Button Content="Button" Height="50" Name="button2" VerticalAlignment="Top" Width="Auto" />
    <Button Content="Button" Height="50" Name="button3" VerticalAlignment="Top" Width="Auto" />
    <Button Content="Button" Height="50" Name="button4" VerticalAlignment="Top" Width="Auto" />
    <Button Content="Button" Height="50" Name="button5" VerticalAlignment="Top" Width="Auto" />
    <Button Content="Button" Height="50" Name="button6" VerticalAlignment="Top" Width="Auto" />
    </StackPanel>
    </GroupBox>
    </Window>

    and it works fine without any abnormal figure. I'm wondering if something in your xaml goes wrong.

    If you want to reduce the distance between the top boder and the windows inner border, you might modify the margin of your GroupBox with it top margin to minus value, for example Margin="0,-10,0,0" or enlarge the value of top margin to enlarge the distance.

    May it helps~


    Ouch Liu
    Welcome to visit by blog: Ouch@點部落
    Friday, February 11, 2011 11:08 AM

All replies

  • I just tried with the following xaml:

    <Window x:Class="WpfGroupBox.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
    <GroupBox Header="Search" BorderThickness="2" BorderBrush="Black" Margin="0,2,0,0" Padding="0,1,0,0">
    <StackPanel>
    <Button Content="Button" Height="50" Name="button1" Width="Auto" />
    <Button Content="Button" Height="50" Name="button2" VerticalAlignment="Top" Width="Auto" />
    <Button Content="Button" Height="50" Name="button3" VerticalAlignment="Top" Width="Auto" />
    <Button Content="Button" Height="50" Name="button4" VerticalAlignment="Top" Width="Auto" />
    <Button Content="Button" Height="50" Name="button5" VerticalAlignment="Top" Width="Auto" />
    <Button Content="Button" Height="50" Name="button6" VerticalAlignment="Top" Width="Auto" />
    </StackPanel>
    </GroupBox>
    </Window>

    and it works fine without any abnormal figure. I'm wondering if something in your xaml goes wrong.

    If you want to reduce the distance between the top boder and the windows inner border, you might modify the margin of your GroupBox with it top margin to minus value, for example Margin="0,-10,0,0" or enlarge the value of top margin to enlarge the distance.

    May it helps~


    Ouch Liu
    Welcome to visit by blog: Ouch@點部落
    Friday, February 11, 2011 11:08 AM
  • Hi Syed Shakeer Hussain,

    Based on your description and code snippet, I have not reproduced your issue, so I think it is hard to find the root cause of your issue.

    If your issue persists, could you share a simple sample with me to reproduce your issue, I think it will be very beneficial for me to resolve your issue.

     

    Best regareds,


    Sheldon _Xiao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, February 14, 2011 8:26 AM
    Moderator
  • Hi Syed Shakeer Hussain,

    I am closing your thread as "Answered", if you have new findings about your issue, please unmark.

     

    Best regards,


    Sheldon _Xiao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, February 21, 2011 6:32 AM
    Moderator