How to set a specific header height for groupbox? - wpf

As the title say, I need to know how can I set a specific header height for a GroupBox, suppose I've this:
<GroupBox Header="Test">
</GroupBox>
this will display an header height based on the content of the header, but is possible also set a specific header height? How?
Thanks.

Instead of using a string for setting the GroupBox Header property, use directly a TextBlock, something like that:
<GroupBox>
<GroupBox.Header>
<TextBlock Text="High Header" VerticalAlignment="Bottom" MinHeight="100" />
</GroupBox.Header>
<Button Content="Button1" />
</GroupBox>

Related

Placing a CheckBox in the Header of a GroupBox

I'm wanting to have a CheckBox as the Header in a GroupBox but all I'm getting in the Header is: System.Windows.Controls.CheckBox Content:My CheckBoxHeader IsChecked:False
<GroupBox>
<GroupBox.Header>
<CheckBox Content="My CheckBoxHeader" />
</GroupBox.Header>
</GroupBox>
Any ideas?
Edit:
This is in a simple UserControl.

How to change the header background of a GroupBox?

How can I change the Background of the header of a GroupBox?
I'm trying to do that with:
<GroupBox Grid.Row="0">
<GroupBox.Header>
<Setter Property="Background" //<- no backgroundproperty
there is no Background property
You can define a Border in the Header and set the Background of it to your desired color:
<GroupBox >
<GroupBox.Header>
<Border Background="Red">
<Label Content="Hello"></Label>
</Border>
</GroupBox.Header>
</GroupBox>
You could set the Header property to any UI element including a Grid or a Border for example:
<GroupBox>
<GroupBox.Header>
<Border Background="Green">
<TextBlock Text="header..." />
</Border>
</GroupBox.Header>
<TextBlock Text="content..."></TextBlock>
</GroupBox>
Take a look at this site: Control Templates, Styles, and Triggers
this is probably more than you need, but it explains how to use a control template to modify controls in various ways. I use this particular control (with different colors) for groupboxes on one of my applications, and it has come in very handy.

WPF : Can we make groupbox header editable at runtime

i want groupbox's header editable that means at runtime i want it to be open for edit like we do rename in microsoft excelsheet in bottom left.
i came to know we can do it by control template but don't know how to write template for it.
It's easy to create Editable Header:
<GroupBox>
<GroupBox.HeaderTemplate>
<DataTemplate>
<TextBox Text="Editable Header"/>
</DataTemplate>
</GroupBox.HeaderTemplate>
<TextBlock Text="Some Content" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</GroupBox>
Or if you want to modify the template of all control?
Then you can find sample here: https://msdn.microsoft.com/en-us/library/vstudio/ms744748(v=vs.100).aspx

How do I have a seperate padding for groupbox header and groupbox content

I have a groupbox, but I want to had a padding of 5 all around the header, but no margin around the content.
How would I best go about this? I can't seem to find a way to seperate the padding values from each other...
here a simple example
<GroupBox Height="100" Width="200">
<GroupBox.Header>
<TextBlock Text="HEADER" Margin="10"></TextBlock>
</GroupBox.Header>
<Rectangle Fill="Blue"></Rectangle>
</GroupBox>

Silverlight TextBlock TextTrimming inside ContentControl disappears

I'm displaying a series of messages (like emails) on a Grid:
<layout:TransitioningContentControl Name="tccCmdMessage" Margin="0,4">
<layout:TransitioningContentControl.ContentTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Title}" FontWeight="SemiBold" />
<TextBlock Name="tbCmdMessage" Text="{Binding Message}" TextTrimming="WordEllipsis" />
</StackPanel>
</DataTemplate>
</layout:TransitioningContentControl.ContentTemplate>
</layout:TransitioningContentControl>
However, the tbCmdMessage never displays. If I remove the TextTrimming (or change it to None) it works. Alternatively if I don't use a ContentControl parent it also works.
Any ideas?
Take a look at this link: http://social.msdn.microsoft.com/Forums/eu/wpf/thread/30fd3279-7bc8-424f-9ee6-41b9f9589a1a.
I suppose explicitly specifying the Width (or MaxWidth) of the StackPanel can make the texts trimmed. You can also try to use another type of container, like Grid.
Other links with similar issue described:
Silverlight text trimming and wrapping issue
TextTrimming not working
http://forums.silverlight.net/t/58227.aspx/1

Resources