Skip to content
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

integrate groupbox control #3913

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions samples/ControlCatalog/MainView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<TabItem Header="TextBlock"><pages:TextBlockPage/></TabItem>
<TabItem Header="ToolTip"><pages:ToolTipPage/></TabItem>
<TabItem Header="TreeView"><pages:TreeViewPage/></TabItem>
<TabItem Header="GroupBox"><pages:GroupBoxPage/></TabItem>
danwalmsley marked this conversation as resolved.
Show resolved Hide resolved
<TabItem Header="Viewbox"><pages:ViewboxPage/></TabItem>
<TabControl.Tag>
<StackPanel Width="115" Spacing="4" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="8">
Expand Down
13 changes: 13 additions & 0 deletions samples/ControlCatalog/Pages/GroupBoxPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ControlCatalog.Pages.GroupBoxPage">
<StackPanel Orientation="Vertical" Spacing="4">
<TextBlock Classes="h1">GroupBox</TextBlock>
<TextBlock Classes="h2">A group box control</TextBlock>

<GroupBox Margin="10" Header="Title" Width="200">
<TextBlock Text="Group box content"/>
</GroupBox>

</StackPanel>
</UserControl>
19 changes: 19 additions & 0 deletions samples/ControlCatalog/Pages/GroupBoxPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;

namespace ControlCatalog.Pages
{
public class GroupBoxPage : UserControl
{
public GroupBoxPage()
{
this.InitializeComponent();
}

private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
}
23 changes: 23 additions & 0 deletions src/Avalonia.Controls/GroupBox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Avalonia.Controls.Primitives;
using Avalonia.Input;

namespace Avalonia.Controls
{
/// <summary>
/// GroupBox Control class
/// </summary>
public class GroupBox: HeaderedContentControl
{
/// <summary>
/// override some metadata:
/// Focusable: false
/// TabNavigation: None
/// </summary>
static GroupBox()
{
FocusableProperty.OverrideMetadata<GroupBox>(new StyledPropertyMetadata<bool>(false));
KeyboardNavigation.TabNavigationProperty.OverrideMetadata<GroupBox>
(new StyledPropertyMetadata<KeyboardNavigationMode>(KeyboardNavigationMode.None));
}
}
}
1 change: 1 addition & 0 deletions src/Avalonia.Themes.Default/DefaultTheme.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@
<StyleInclude Source="resm:Avalonia.Themes.Default.WindowNotificationManager.xaml?assembly=Avalonia.Themes.Default"/>
<StyleInclude Source="resm:Avalonia.Themes.Default.NotificationCard.xaml?assembly=Avalonia.Themes.Default"/>
<StyleInclude Source="resm:Avalonia.Themes.Default.NativeMenuBar.xaml?assembly=Avalonia.Themes.Default"/>
<StyleInclude Source="resm:Avalonia.Themes.Default.GroupBox.xaml?assembly=Avalonia.Themes.Default"/>
</Styles>
60 changes: 60 additions & 0 deletions src/Avalonia.Themes.Default/GroupBox.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<Styles
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>

<Styles.Resources>
<Thickness x:Key="GroupBoxHeaderThemePadding">4</Thickness>
</Styles.Resources>

<Style Selector="GroupBox">
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush}" />
mameolan marked this conversation as resolved.
Show resolved Hide resolved
<Setter Property="BorderBrush" Value="{DynamicResource ThemeAccentBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="FontSize" Value="{DynamicResource FontSizeNormal}" />
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}" />
<Setter Property="Padding" Value="4" />
<Setter Property="Margin" Value="1" />
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>

<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Grid x:Name="GroupBoxRoot">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Border x:Name="HeaderSite"
Grid.Row="0"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
UseLayoutRounding="True">
<ContentControl x:Name="HeaderContent"
Margin="{DynamicResource GroupBoxHeaderThemePadding}"
Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
FontFamily="{TemplateBinding FontFamily}"
FontSize="{TemplateBinding FontSize}"
FontWeight="{TemplateBinding FontWeight}"
UseLayoutRounding="False" />
</Border>
<Border Grid.Row="1"
Background="Transparent"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{Binding RelativeSource={RelativeSource TemplatedParent},
Path=BorderThickness}"
UseLayoutRounding="True">
<ContentPresenter Margin="{TemplateBinding Padding}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Cursor="{TemplateBinding Cursor}"
UseLayoutRounding="False" />
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Styles>