WPF GroupBox Header Text Issue
11,176
Solution 1
You likely have changed GroupBox
's HeaderTemplate
and this template supports displaying only text.
Solution 2
Header
is defined more than once.
<GroupBox Name="RulesGroupBox">
<GroupBox.Header>
<TextBlock FontWeight="Bold" Text="Rules"></TextBlock>
</GroupBox.Header>
<StackPanel Name="RulesStackPanel"
HorizontalAlignment="Left">
....
</StackPanel>
</GroupBox>
"Rules" appears in bold with this correction.
Edit : This answer was made for the question before it has been edited. It's clearly not the good answer for the edited question.
Author by
BrianKE
Updated on June 04, 2022Comments
-
BrianKE almost 2 years
I have the following XAML which displays correctly:
<GroupBox Name="RulesGroupBox" Header="Rules"> <StackPanel Name="RulesStackPanel" HorizontalAlignment="Left"> .... </StackPanel> </GroupBox>
I now want to make the header text bold using the following (which I know works in other projects):
<GroupBox Name="RulesGroupBox"> <GroupBox.Header> <TextBlock FontWeight="Bold" Text="Rules"></TextBlock> </GroupBox.Header> <StackPanel Name="RulesStackPanel" HorizontalAlignment="Left"> .... </StackPanel> </GroupBox>
For some reason, in this project, this change has the effect of making the text displayed for the Header text "System.Windows.Controls.TextBlock" and not "Rules". The text is now bold but not displaying "Rules".
Any idea why the chagne would not show "Rules" in bold?
-
Athari almost 10 yearsIt's a typo in the question. WPF won't compile XAML with duplicate properties, IIRC, so your correction achieves nothing.
-
BrianKE almost 10 yearsThe duplicate header was a typo int he original post. I have updated the post with correct XAML.
-
Xaruth almost 10 yearsOK, so error comes from elsewhere, not from this corrected code.
-
Xaruth almost 10 yearsIn a simple example, just with that code, header is in bold like you want. Please give us more details !
-
BrianKE almost 10 yearsThank you. It was being defined in a global dictionary that I was not aware of.