-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GroupBox] Missing #823
Comments
Is this still being considered or is it old? |
Probably the issue should be closed: #3913 |
Yeah, I think agreed. I also saw that PR and it seems the conclusion was it's not going to be added because "It is just a styled HeaderedContentControl"? |
For people who look at this in the future (which I'm sure will be the case unless one day Avalonia officially implements
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. 2024-03-18 - Release v1.0.0https://github.com/BinToss/GroupBox.Avalonia/releases/v1.0.0 2023-07-11Notes:
Fixed:
Known Issues:
TODO:
GroupBoxSimpleClassic.axaml<Styles
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:CompileBindings="True"
xmlns:conv="clr-namespace:HXE.GUI.Converters;assembly=HXE">
<Style Selector="HeaderedContentControl">
<SimpleTheme />
<Style.Resources>
<conv:RectGeometryConverter x:Key="rectConv" />
<Thickness x:Key="BorderMargin">0,10,0,0</Thickness>
<Thickness x:Key="BorderPadding">5,10,5,5</Thickness>
</Style.Resources>
<Setter
Property="Template">
<Setter.Value>
<ControlTemplate>
<Grid Name="GBGrid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Name="GBHeaderText"
Margin="5,0,0,0"
Padding="5,0,5,0"
ZIndex="1"
TextBlock.FontWeight="Bold" Text="{TemplateBinding Header}">
</TextBlock>
<Border Name="GBBorder"
Grid.RowSpan="2" Grid.ColumnSpan="2"
Margin="{DynamicResource BorderMargin}"
Padding="{DynamicResource BorderPadding}"
BorderBrush="{TemplateBinding Foreground}"
BorderThickness="1">
<Rectangle
Height="{Binding #GBContent.Height}"
Width="{Binding #GBContent.Width}" />
<Border.Clip>
<CombinedGeometry
GeometryCombineMode="Exclude"
Geometry1="{Binding #GBGrid.Bounds, Mode=OneWay, Converter={StaticResource rectConv}}"
Geometry2="{Binding #GBHeaderText.Bounds, Mode=OneWay, Converter={StaticResource rectConv}}" />
</Border.Clip>
</Border>
<Border Name="GBContent"
Grid.RowSpan="2" Grid.ColumnSpan="2"
Margin="{DynamicResource BorderMargin}"
Padding="{DynamicResource BorderPadding}"
BorderThickness="0">
<ContentPresenter Content="{TemplateBinding Content}" />
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Styles> RectGeometryConverter.csusing System;
using System.Globalization;
using Avalonia;
using Avalonia.Data;
using Avalonia.Data.Converters;
using Avalonia.Media;
namespace HXE.GUI.Converters;
public class RectGeometryConverter : IValueConverter
{
public static readonly RectGeometryConverter Instance = new();
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is Rect rect)
return new RectangleGeometry(rect);
// converter used for the wrong type
return new BindingNotification(new InvalidCastException(), BindingErrorType.Error);
}
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is RectangleGeometry rectangle)
return rectangle.Rect;
// converter used for the wrong type
return new BindingNotification(new InvalidCastException(), BindingErrorType.Error);
}
} 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.
|
@BinToss Thank you for your styles. It's very useful. And I found replacing the CombinedGeometry with a MultiBinding solves the first known issue.
|
i am absulute newbee. |
I do have a sample project, but I'm still working out the kinks. In
BinToss/GroupBox.Avalonia, I'm trying to use control themes instead of
styles and have been running into issues like borders being consistently cut
off.
Eventually, I'll package my control themes and push them to NuGet for others to use more easily.
…On Thu, Dec 28, 2023, 03:47 postrondev ***@***.***> wrote:
i am absulute newbee.
do have a small complete example how to use it in a control dll?
thx.
—
Reply to this email directly, view it on GitHub
<#823 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABXILNWREESTFUYTVYHODKLYLVL47AVCNFSM4CZPLNO2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBXGEYDSMJTGYZA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
https://github.com/BinToss/GroupBox.Avalonia/releases/v1.0.0 |
There 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:The text was updated successfully, but these errors were encountered: