committed by
GitHub
7 changed files with 178 additions and 0 deletions
@ -0,0 +1,8 @@ |
|||
using Avalonia.Controls.Primitives; |
|||
|
|||
namespace Avalonia.Controls; |
|||
|
|||
public class GroupBox : HeaderedContentControl |
|||
{ |
|||
|
|||
} |
|||
@ -0,0 +1,80 @@ |
|||
<ResourceDictionary xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
x:ClassModifier="internal"> |
|||
<Design.PreviewWith> |
|||
<GroupBox Padding="10" Margin="10"> |
|||
<TextBlock Text="Hello World" /> |
|||
</GroupBox> |
|||
</Design.PreviewWith> |
|||
|
|||
<ControlTheme x:Key="{x:Type GroupBox}" |
|||
TargetType="GroupBox"> |
|||
<Setter Property="BorderThickness" Value="{DynamicResource GroupBoxBorderThickness}" /> |
|||
<Setter Property="Background" Value="{DynamicResource GroupBoxBackground}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource GroupBoxBorderBrush}" /> |
|||
<Setter Property="Padding" Value="{DynamicResource GroupBoxPadding}" /> |
|||
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Grid x:Name="RootGrid" UseLayoutRounding="true" ColumnDefinitions="6,Auto,*,6" RowDefinitions="Auto,Auto,*,6"> |
|||
<!-- Separate Border for the background because if the background is set in the Border with the Header the opacity mask will be applied to the background as well. --> |
|||
<Border Grid.Row="1" |
|||
Grid.RowSpan="3" |
|||
Grid.Column="0" |
|||
Grid.ColumnSpan="4" |
|||
CornerRadius="{TemplateBinding CornerRadius}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
BorderBrush="Transparent" |
|||
Background="{TemplateBinding Background}"/> |
|||
|
|||
<Border Grid.Row="1" |
|||
Grid.RowSpan="3" |
|||
Grid.ColumnSpan="4" |
|||
CornerRadius="{TemplateBinding CornerRadius}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
BorderBrush="{TemplateBinding BorderBrush}"> |
|||
<Border.Clip> |
|||
<CombinedGeometry GeometryCombineMode="Exclude"> |
|||
<CombinedGeometry.Geometry1> |
|||
<RectangleGeometry Rect="{Binding #RootGrid.Bounds}" /> |
|||
</CombinedGeometry.Geometry1> |
|||
<CombinedGeometry.Geometry2> |
|||
<RectangleGeometry Rect="{Binding #Header.Bounds}" /> |
|||
</CombinedGeometry.Geometry2> |
|||
</CombinedGeometry> |
|||
</Border.Clip> |
|||
</Border> |
|||
|
|||
<!-- ContentPresenter for the header --> |
|||
<Border x:Name="Header" |
|||
Padding="3,0,3,0" |
|||
Grid.Row="0" |
|||
Grid.RowSpan="2" |
|||
Grid.Column="1"> |
|||
<ContentPresenter Name="PART_HeaderPresenter" |
|||
Content="{TemplateBinding Header}" |
|||
RecognizesAccessKey="True" |
|||
FontSize="{DynamicResource GroupBoxHeaderFontSize}" |
|||
Foreground="{DynamicResource GroupBoxHeaderForeground}" |
|||
ContentTemplate="{TemplateBinding HeaderTemplate}" |
|||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" |
|||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" |
|||
UseLayoutRounding="{TemplateBinding UseLayoutRounding}" /> |
|||
</Border> |
|||
<!-- Primary content for GroupBox --> |
|||
<ContentPresenter Grid.Row="2" |
|||
Grid.Column="1" |
|||
Grid.ColumnSpan="2" |
|||
Name="PART_ContentPresenter" |
|||
ContentTemplate="{TemplateBinding ContentTemplate}" |
|||
Content="{TemplateBinding Content}" |
|||
RecognizesAccessKey="True" |
|||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" |
|||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" |
|||
UseLayoutRounding="{TemplateBinding UseLayoutRounding}" |
|||
Margin="{TemplateBinding Padding}" /> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</ControlTheme> |
|||
</ResourceDictionary> |
|||
@ -0,0 +1,76 @@ |
|||
<ResourceDictionary xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
x:ClassModifier="internal"> |
|||
<Design.PreviewWith> |
|||
<GroupBox Padding="10" Margin="10"> |
|||
<TextBlock Text="Hello World" /> |
|||
</GroupBox> |
|||
</Design.PreviewWith> |
|||
|
|||
<ControlTheme x:Key="{x:Type GroupBox}" |
|||
TargetType="GroupBox"> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/> |
|||
<Setter Property="BorderThickness" Value="1"/> |
|||
<Setter Property="CornerRadius" Value="4"/> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Grid x:Name="RootGrid" UseLayoutRounding="true" ColumnDefinitions="6,Auto,*,6" RowDefinitions="Auto,Auto,*,6"> |
|||
<!-- Separate Border for the background because if the background is set in the Border with the Header the opacity mask will be applied to the background as well. --> |
|||
<Border Grid.Row="1" |
|||
Grid.RowSpan="3" |
|||
Grid.Column="0" |
|||
Grid.ColumnSpan="4" |
|||
CornerRadius="{TemplateBinding CornerRadius}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
BorderBrush="Transparent" |
|||
Background="{TemplateBinding Background}"/> |
|||
|
|||
<Border Grid.Row="1" |
|||
Grid.RowSpan="3" |
|||
Grid.ColumnSpan="4" |
|||
CornerRadius="{TemplateBinding CornerRadius}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
BorderBrush="{TemplateBinding BorderBrush}"> |
|||
<Border.Clip> |
|||
<CombinedGeometry GeometryCombineMode="Exclude"> |
|||
<CombinedGeometry.Geometry1> |
|||
<RectangleGeometry Rect="{Binding #RootGrid.Bounds}" /> |
|||
</CombinedGeometry.Geometry1> |
|||
<CombinedGeometry.Geometry2> |
|||
<RectangleGeometry Rect="{Binding #Header.Bounds}" /> |
|||
</CombinedGeometry.Geometry2> |
|||
</CombinedGeometry> |
|||
</Border.Clip> |
|||
</Border> |
|||
|
|||
<!-- ContentPresenter for the header --> |
|||
<Border x:Name="Header" |
|||
Padding="3,0,3,0" |
|||
Grid.Row="0" |
|||
Grid.RowSpan="2" |
|||
Grid.Column="1"> |
|||
<ContentPresenter Name="PART_HeaderPresenter" |
|||
Content="{TemplateBinding Header}" |
|||
RecognizesAccessKey="True" |
|||
ContentTemplate="{TemplateBinding HeaderTemplate}" |
|||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" |
|||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" |
|||
UseLayoutRounding="{TemplateBinding UseLayoutRounding}" /> |
|||
</Border> |
|||
<!-- Primary content for GroupBox --> |
|||
<ContentPresenter Grid.Row="2" |
|||
Grid.Column="1" |
|||
Grid.ColumnSpan="2" |
|||
Name="PART_ContentPresenter" |
|||
ContentTemplate="{TemplateBinding ContentTemplate}" |
|||
Content="{TemplateBinding Content}" |
|||
RecognizesAccessKey="True" |
|||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" |
|||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" |
|||
UseLayoutRounding="{TemplateBinding UseLayoutRounding}" |
|||
Margin="{TemplateBinding Padding}" /> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</ControlTheme> |
|||
</ResourceDictionary> |
|||
Loading…
Reference in new issue