[GroupBox] Missing
See original GitHub issueThere is no GroupBox
like In WPF. Although it’s not essential, this control is useful to label groups of controls.
TEMPORARY TRICK:
Although it doesn’t exist, it can be emulated with a HeaderedContentControl
with a custom Style:
<Style Selector="HeaderedContentControl">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border>
<StackPanel>
<ContentPresenter TextBlock.FontWeight="Bold" Content="{TemplateBinding Header}" />
<Border
BorderBrush="{TemplateBinding Background}"
BorderThickness="2"
CornerRadius="5">
<ContentPresenter Content="{TemplateBinding Content}" />
</Border>
</StackPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Issue Analytics
- State:
- Created 7 years ago
- Reactions:8
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Groupbox disappeared in Visual Studio C# Winform
I've created a GroupBox with some buttons, topdowns and labels in it. But in the preview it disappeared. I still have the code...
Read more >groupbox missing from my toolbox
associated with "System.Windows.Forms" do show up in my VS8 toolbox. Currently I am using a panel to group controls. It is missing a...
Read more >Panel or Groupbox is missing in toolBox
Windows Forms designer in Visual Studio 16.5 Preview 1 Net Core 3.1 - Panel or Groupbox is missing in toolBoxClosed - Not Enough...
Read more >Solved: Edit Group box disappeared - REVIT 2011
Solved: When I'm in the Group Edit mode, the box disappeared and I have no way to close the group. This is in...
Read more >Group Box Header Titles Do Not Display on Employee Event ...
On the Plan Type page of the Employee Event Details component, the group box labels are missing; instead they display as "Group Box...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For people who look at this in the future (which I’m sure will be the case unless one day Avalonia officially implements
GroupBox
), the workaround by @SuperJMN is great - you just have to assign theBorder
property, which is different from how normal WPF works (I think it’s just black by default):But if you want something a little more classic-style, I created this:
I’ll edit this issue to hide the WIP portion when its main issues are resolved.
Discussion found here.
2023-07-11
Notes:
<AvaloniaResource Include="GUI\Styles\*.axaml" />
. Do not include AXAML files which have code-behind.Avalonia.Themes.Simple
. When using the Simple theme, ensure it’s added and untrimmed e.g.<PackageReference Include="Avalonia.Themes.Simple" Version="11.0.0" />
and<TrimmerRootAssembly Include="Avalonia.Themes.Simple" />
Fixed:
Known Issues:
TODO:
GroupBoxSimpleClassic.axaml
RectGeometryConverter.cs
2023-06-26
@derekantrican’s examples are great, but the Classic style in that example will not adapt to Theme or Style changes i.e. Header background will remain solid white when the “real” background changes. I’ve considered two solutions to this. One utlizes the Border’s Clip property. The other utilizes the Border’s OpacityMask. I’m attempting the former, but I’m struggling to make the Clip geometry recalculate when the source Bounds change. Both will likely require classes for conversions and/or observers.
Border.Clip = BoundsA - BoundsB
(Click to see images) At one point, I was excluding
GBHeader.Bounds
(GBHeader being the Border containing the text block in the original example) fromGBContent.Bounds
, but an unexpectedly large part of the latter's Border is clipped despite the resulting geometry not affecting that region according the Dev Tools.(Click to see images) However, I now exclude
GBHeaderText.Bounds
fromGBGrid.Bounds
to avoid that particular issue.This implementation currently has two issues.
CombinedGeometry
assigned toGBContent.Clip
is not recalculated when theRect
-value Bounds it was created from have changed.CombinedGeomtry
assigned toGBContent.Clip
partially obscures the presented contents. I believe this could be remedied by getting theTransformBounds
, but the lack of this property in my Avalonia 11.0.0-rc1.1 application’s Dev Tools window indicates it no longer exists or may be inaccessible under certain conditions. The suspected issue is that two Bounds have different origin points relative to the window, so excluding one Bounds from the other will result in one being offset from its expected position in the CombinedGeometryGroupBoxClassic.axaml
RectGeometryConverter.cs