chore: complete avalonia button style.
This commit is contained in:
1 parent
8a31a48b29
commit
2f0b39773e
17 files changed
+1990
-177
No files matched your search
@@ -1,6 +1,6 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol">
|
||||
xmlns:hc="clr-namespace:HandyControl.Controls">
|
||||
<ControlTheme x:Key="ButtonBaseStyle"
|
||||
TargetType="Button">
|
||||
<Setter Property="Height"
|
||||
@@ -23,21 +23,37 @@
|
||||
Value="{DynamicResource BorderBrush}" />
|
||||
<Setter Property="BorderThickness"
|
||||
Value="1" />
|
||||
<Setter Property="CornerRadius"
|
||||
<Setter Property="hc:BorderElement.CornerRadius"
|
||||
Value="{StaticResource DefaultCornerRadius}" />
|
||||
<Setter Property="CornerRadius"
|
||||
Value="{Binding $self.(hc:BorderElement.CornerRadius)}" />
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<ContentPresenter x:Name="PART_ContentPresenter"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}"
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
RecognizesAccessKey="True"
|
||||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
|
||||
<Grid>
|
||||
<Border Background="{TemplateBinding Background}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}" />
|
||||
<Border BorderThickness="{TemplateBinding BorderThickness}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}">
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Margin="{TemplateBinding Padding}">
|
||||
<Path Width="{TemplateBinding hc:IconElement.Width}"
|
||||
Height="{TemplateBinding hc:IconElement.Height}"
|
||||
Fill="{TemplateBinding Foreground}"
|
||||
IsVisible="{Binding Path=(hc:IconElement.Geometry), RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static ObjectConverters.IsNotNull}}"
|
||||
Stretch="Uniform"
|
||||
Data="{TemplateBinding hc:IconElement.Geometry}" />
|
||||
<ContentPresenter RecognizesAccessKey="True"
|
||||
VerticalAlignment="Center"
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
IsVisible="{Binding $self.Content, Converter={x:Static ObjectConverters.IsNotNull}}"
|
||||
Margin="{Binding Path=(hc:IconElement.Geometry), RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource GeometrySpacingConverter}, ConverterParameter='6,0,0,0'}" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
|
||||
@@ -57,32 +73,6 @@
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonDashedBaseStyle"
|
||||
BasedOn="{StaticResource ButtonBaseStyle}"
|
||||
TargetType="Button">
|
||||
<Setter Property="Background"
|
||||
Value="Transparent" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<hc:DashedBorder BorderDashArray="3,2"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}">
|
||||
<ContentPresenter x:Name="PART_ContentPresenter"
|
||||
Background="{TemplateBinding Background}"
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
RecognizesAccessKey="True"
|
||||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
|
||||
</hc:DashedBorder>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonDefault"
|
||||
BasedOn="{StaticResource ButtonBaseStyle}"
|
||||
TargetType="Button">
|
||||
@@ -100,6 +90,17 @@
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonDefault.Small"
|
||||
BasedOn="{StaticResource ButtonDefault}"
|
||||
TargetType="Button">
|
||||
<Setter Property="Height"
|
||||
Value="20" />
|
||||
<Setter Property="Padding"
|
||||
Value="6,1" />
|
||||
<Setter Property="hc:IconElement.Height"
|
||||
Value="12" />
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="{x:Type Button}"
|
||||
BasedOn="{StaticResource ButtonDefault}"
|
||||
TargetType="Button" />
|
||||
@@ -113,6 +114,17 @@
|
||||
Value="{DynamicResource PrimaryBrush}" />
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonPrimary.Small"
|
||||
BasedOn="{StaticResource ButtonPrimary}"
|
||||
TargetType="Button">
|
||||
<Setter Property="Height"
|
||||
Value="20" />
|
||||
<Setter Property="Padding"
|
||||
Value="6,1" />
|
||||
<Setter Property="hc:IconElement.Height"
|
||||
Value="12" />
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonSuccess"
|
||||
BasedOn="{StaticResource ButtonBaseStyle}"
|
||||
TargetType="Button">
|
||||
@@ -122,6 +134,17 @@
|
||||
Value="{DynamicResource SuccessBrush}" />
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonSuccess.Small"
|
||||
BasedOn="{StaticResource ButtonSuccess}"
|
||||
TargetType="Button">
|
||||
<Setter Property="Height"
|
||||
Value="20" />
|
||||
<Setter Property="Padding"
|
||||
Value="6,1" />
|
||||
<Setter Property="hc:IconElement.Height"
|
||||
Value="12" />
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonInfo"
|
||||
BasedOn="{StaticResource ButtonBaseStyle}"
|
||||
TargetType="Button">
|
||||
@@ -131,6 +154,17 @@
|
||||
Value="{DynamicResource InfoBrush}" />
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonInfo.Small"
|
||||
BasedOn="{StaticResource ButtonInfo}"
|
||||
TargetType="Button">
|
||||
<Setter Property="Height"
|
||||
Value="20" />
|
||||
<Setter Property="Padding"
|
||||
Value="6,1" />
|
||||
<Setter Property="hc:IconElement.Height"
|
||||
Value="12" />
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonWarning"
|
||||
BasedOn="{StaticResource ButtonBaseStyle}"
|
||||
TargetType="Button">
|
||||
@@ -140,6 +174,17 @@
|
||||
Value="{DynamicResource WarningBrush}" />
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonWarning.Small"
|
||||
BasedOn="{StaticResource ButtonWarning}"
|
||||
TargetType="Button">
|
||||
<Setter Property="Height"
|
||||
Value="20" />
|
||||
<Setter Property="Padding"
|
||||
Value="6,1" />
|
||||
<Setter Property="hc:IconElement.Height"
|
||||
Value="12" />
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonDanger"
|
||||
BasedOn="{StaticResource ButtonBaseStyle}"
|
||||
TargetType="Button">
|
||||
@@ -149,6 +194,51 @@
|
||||
Value="{DynamicResource DangerBrush}" />
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonDanger.Small"
|
||||
BasedOn="{StaticResource ButtonDanger}"
|
||||
TargetType="Button">
|
||||
<Setter Property="Height"
|
||||
Value="20" />
|
||||
<Setter Property="Padding"
|
||||
Value="6,1" />
|
||||
<Setter Property="hc:IconElement.Height"
|
||||
Value="12" />
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonDashedBaseStyle"
|
||||
BasedOn="{StaticResource ButtonBaseStyle}"
|
||||
TargetType="Button">
|
||||
<Setter Property="Background"
|
||||
Value="Transparent" />
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="Button">
|
||||
<hc:DashedBorder BorderDashArray="3,2"
|
||||
Background="Transparent"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}">
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Margin="{TemplateBinding Padding}">
|
||||
<Path Width="{TemplateBinding hc:IconElement.Width}"
|
||||
Height="{TemplateBinding hc:IconElement.Height}"
|
||||
Fill="{TemplateBinding Foreground}"
|
||||
IsVisible="{Binding Path=(hc:IconElement.Geometry), RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static ObjectConverters.IsNotNull}}"
|
||||
Stretch="Uniform"
|
||||
Data="{TemplateBinding hc:IconElement.Geometry}" />
|
||||
<ContentPresenter RecognizesAccessKey="True"
|
||||
VerticalAlignment="Center"
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
IsVisible="{Binding $self.Content, Converter={x:Static ObjectConverters.IsNotNull}}"
|
||||
Margin="{Binding Path=(hc:IconElement.Geometry), RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource GeometrySpacingConverter}, ConverterParameter='6,0,0,0'}" />
|
||||
</StackPanel>
|
||||
</hc:DashedBorder>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonDashed"
|
||||
BasedOn="{StaticResource ButtonDashedBaseStyle}"
|
||||
TargetType="Button">
|
||||
@@ -163,6 +253,17 @@
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonDashed.Small"
|
||||
BasedOn="{StaticResource ButtonDashed}"
|
||||
TargetType="Button">
|
||||
<Setter Property="Height"
|
||||
Value="20" />
|
||||
<Setter Property="Padding"
|
||||
Value="6,1" />
|
||||
<Setter Property="hc:IconElement.Height"
|
||||
Value="12" />
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonDashedPrimary"
|
||||
BasedOn="{StaticResource ButtonDashedBaseStyle}"
|
||||
TargetType="Button">
|
||||
@@ -172,6 +273,17 @@
|
||||
Value="{DynamicResource PrimaryBrush}" />
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonDashedPrimary.Small"
|
||||
BasedOn="{StaticResource ButtonDashedPrimary}"
|
||||
TargetType="Button">
|
||||
<Setter Property="Height"
|
||||
Value="20" />
|
||||
<Setter Property="Padding"
|
||||
Value="6,1" />
|
||||
<Setter Property="hc:IconElement.Height"
|
||||
Value="12" />
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonDashedSuccess"
|
||||
BasedOn="{StaticResource ButtonDashedBaseStyle}"
|
||||
TargetType="Button">
|
||||
@@ -181,6 +293,17 @@
|
||||
Value="{DynamicResource SuccessBrush}" />
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonDashedSuccess.Small"
|
||||
BasedOn="{StaticResource ButtonDashedSuccess}"
|
||||
TargetType="Button">
|
||||
<Setter Property="Height"
|
||||
Value="20" />
|
||||
<Setter Property="Padding"
|
||||
Value="6,1" />
|
||||
<Setter Property="hc:IconElement.Height"
|
||||
Value="12" />
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonDashedInfo"
|
||||
BasedOn="{StaticResource ButtonDashedBaseStyle}"
|
||||
TargetType="Button">
|
||||
@@ -190,6 +313,17 @@
|
||||
Value="{DynamicResource InfoBrush}" />
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonDashedInfo.Small"
|
||||
BasedOn="{StaticResource ButtonDashedInfo}"
|
||||
TargetType="Button">
|
||||
<Setter Property="Height"
|
||||
Value="20" />
|
||||
<Setter Property="Padding"
|
||||
Value="6,1" />
|
||||
<Setter Property="hc:IconElement.Height"
|
||||
Value="12" />
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonDashedWarning"
|
||||
BasedOn="{StaticResource ButtonDashedBaseStyle}"
|
||||
TargetType="Button">
|
||||
@@ -199,6 +333,17 @@
|
||||
Value="{DynamicResource WarningBrush}" />
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonDashedWarning.Small"
|
||||
BasedOn="{StaticResource ButtonDashedWarning}"
|
||||
TargetType="Button">
|
||||
<Setter Property="Height"
|
||||
Value="20" />
|
||||
<Setter Property="Padding"
|
||||
Value="6,1" />
|
||||
<Setter Property="hc:IconElement.Height"
|
||||
Value="12" />
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonDashedDanger"
|
||||
BasedOn="{StaticResource ButtonDashedBaseStyle}"
|
||||
TargetType="Button">
|
||||
@@ -207,4 +352,154 @@
|
||||
<Setter Property="BorderBrush"
|
||||
Value="{DynamicResource DangerBrush}" />
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonDashedDanger.Small"
|
||||
BasedOn="{StaticResource ButtonDashedDanger}"
|
||||
TargetType="Button">
|
||||
<Setter Property="Height"
|
||||
Value="20" />
|
||||
<Setter Property="Padding"
|
||||
Value="6,1" />
|
||||
<Setter Property="hc:IconElement.Height"
|
||||
Value="12" />
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonIcon"
|
||||
BasedOn="{StaticResource ButtonBaseStyle}"
|
||||
TargetType="Button">
|
||||
<Setter Property="Background"
|
||||
Value="Transparent" />
|
||||
<Setter Property="BorderBrush"
|
||||
Value="Transparent" />
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource PrimaryTextBrush}" />
|
||||
<Setter Property="hc:BorderElement.CornerRadius"
|
||||
Value="0" />
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<Border BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}">
|
||||
<ContentControl HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Margin="{TemplateBinding Padding}">
|
||||
<Path Fill="{TemplateBinding Foreground}"
|
||||
Stretch="Uniform"
|
||||
Width="{TemplateBinding hc:IconElement.Width}"
|
||||
Height="{TemplateBinding hc:IconElement.Height}"
|
||||
Data="{TemplateBinding hc:IconElement.Geometry}" />
|
||||
</ContentControl>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonIcon.Small"
|
||||
BasedOn="{StaticResource ButtonIcon}"
|
||||
TargetType="Button">
|
||||
<Setter Property="Height"
|
||||
Value="20" />
|
||||
<Setter Property="Padding"
|
||||
Value="6,1" />
|
||||
<Setter Property="hc:IconElement.Height"
|
||||
Value="12" />
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonIconCircular"
|
||||
BasedOn="{StaticResource ButtonBaseStyle}"
|
||||
TargetType="Button">
|
||||
<Setter Property="Width"
|
||||
Value="{StaticResource DefaultControlHeight}" />
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource PrimaryTextBrush}" />
|
||||
<Setter Property="hc:BorderElement.CornerRadius"
|
||||
Value="0" />
|
||||
<Setter Property="Padding"
|
||||
Value="6" />
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<Border Theme="{StaticResource BorderCircular}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}">
|
||||
<ContentControl HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Margin="{TemplateBinding Padding}">
|
||||
<Path Fill="{TemplateBinding Foreground}"
|
||||
Stretch="Uniform"
|
||||
Width="{TemplateBinding hc:IconElement.Width}"
|
||||
Height="{TemplateBinding hc:IconElement.Height}"
|
||||
Data="{TemplateBinding hc:IconElement.Geometry}" />
|
||||
</ContentControl>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonIconCircular.Small"
|
||||
BasedOn="{StaticResource ButtonIconCircular}"
|
||||
TargetType="Button">
|
||||
<Setter Property="Width"
|
||||
Value="20" />
|
||||
<Setter Property="Height"
|
||||
Value="20" />
|
||||
<Setter Property="Padding"
|
||||
Value="1" />
|
||||
<Setter Property="hc:IconElement.Height"
|
||||
Value="12" />
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ButtonCustom"
|
||||
TargetType="Button">
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource PrimaryTextBrush}" />
|
||||
<Setter Property="Background"
|
||||
Value="{x:Null}" />
|
||||
<Setter Property="HorizontalContentAlignment"
|
||||
Value="Center" />
|
||||
<Setter Property="VerticalContentAlignment"
|
||||
Value="Center" />
|
||||
<Setter Property="Padding"
|
||||
Value="0" />
|
||||
<Setter Property="BorderThickness"
|
||||
Value="0" />
|
||||
<Setter Property="hc:BorderElement.CornerRadius"
|
||||
Value="{StaticResource DefaultCornerRadius}" />
|
||||
<Setter Property="CornerRadius"
|
||||
Value="{Binding $self.(hc:BorderElement.CornerRadius)}" />
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="Button">
|
||||
<ContentPresenter Padding="{TemplateBinding Padding}"
|
||||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
Background="{TemplateBinding Background}"
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
RecognizesAccessKey="True" />
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
|
||||
<Style Selector="^:pointerover /template/ ContentPresenter">
|
||||
<Setter Property="Opacity"
|
||||
Value="0.9" />
|
||||
<Setter Property="Background"
|
||||
Value="{Binding $self.(hc:BackgroundSwitchElement.MouseHoverBackground)}" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:pressed /template/ ContentPresenter">
|
||||
<Setter Property="Opacity"
|
||||
Value="0.6" />
|
||||
<Setter Property="Background"
|
||||
Value="{Binding $self.(hc:BackgroundSwitchElement.MouseDownBackground)}" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:disabled">
|
||||
<Setter Property="Opacity"
|
||||
Value="0.4" />
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
||||
Reference in new issue
Block a user