committed by
GitHub
13 changed files with 372 additions and 26 deletions
@ -0,0 +1,15 @@ |
|||
namespace Avalonia.Controls |
|||
{ |
|||
/// <summary>
|
|||
/// A button with an added drop-down chevron to visually indicate it has a flyout with additional actions.
|
|||
/// </summary>
|
|||
public class DropDownButton : Button |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="DropDownButton"/> class.
|
|||
/// </summary>
|
|||
public DropDownButton() |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,67 @@ |
|||
<Styles xmlns="https://github.com/avaloniaui"> |
|||
<Style Selector="DropDownButton"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeControlMidBrush}"/> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderLowBrush}"/> |
|||
<Setter Property="BorderThickness" Value="{DynamicResource ThemeBorderThickness}"/> |
|||
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}"/> |
|||
<Setter Property="HorizontalContentAlignment" Value="Center"/> |
|||
<Setter Property="VerticalContentAlignment" Value="Center"/> |
|||
<Setter Property="Padding" Value="4"/> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate> |
|||
<Border Name="RootBorder" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
CornerRadius="{TemplateBinding CornerRadius}" |
|||
ClipToBounds="True"> |
|||
<Grid Name="InnerGrid"> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="*" /> |
|||
<ColumnDefinition Width="Auto" /> |
|||
</Grid.ColumnDefinitions> |
|||
|
|||
<ContentPresenter Name="PART_ContentPresenter" |
|||
Grid.Column="0" |
|||
Content="{TemplateBinding Content}" |
|||
ContentTemplate="{TemplateBinding ContentTemplate}" |
|||
Padding="{TemplateBinding Padding}" |
|||
RecognizesAccessKey="True" |
|||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" |
|||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" /> |
|||
|
|||
<PathIcon Name="DropDownGlyph" |
|||
Grid.Column="1" |
|||
UseLayoutRounding="False" |
|||
IsHitTestVisible="False" |
|||
Height="12" |
|||
Width="12" |
|||
Margin="0,0,10,0" |
|||
HorizontalAlignment="Right" |
|||
VerticalAlignment="Center" /> |
|||
|
|||
</Grid> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="DropDownButton /template/ PathIcon#DropDownGlyph"> |
|||
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}" /> |
|||
<Setter Property="Data" Value="M1939 486L2029 576L1024 1581L19 576L109 486L1024 1401L1939 486Z" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DropDownButton:pointerover /template/ Border#RootBorder"> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/> |
|||
</Style> |
|||
|
|||
<Style Selector="DropDownButton:pressed /template/ Border#RootBorder"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeControlHighBrush}"/> |
|||
</Style> |
|||
|
|||
<Style Selector="DropDownButton:disabled"> |
|||
<Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}"/> |
|||
</Style> |
|||
</Styles> |
|||
@ -0,0 +1,103 @@ |
|||
<Styles xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
x:CompileBindings="True"> |
|||
|
|||
<Design.PreviewWith> |
|||
<Border Padding="20"> |
|||
<StackPanel Spacing="20"> |
|||
<DropDownButton Content="Click Me!" /> |
|||
<DropDownButton Content="Disabled" IsEnabled="False" /> |
|||
</StackPanel> |
|||
</Border> |
|||
</Design.PreviewWith> |
|||
|
|||
<Styles.Resources> |
|||
<x:Double x:Key="DropDownButtonMinHeight">32</x:Double> |
|||
</Styles.Resources> |
|||
|
|||
<Style Selector="DropDownButton"> |
|||
<Setter Property="Background" Value="{DynamicResource ButtonBackground}" /> |
|||
<Setter Property="Foreground" Value="{DynamicResource ButtonForeground}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrush}" /> |
|||
<Setter Property="BorderThickness" Value="{DynamicResource ButtonBorderThemeThickness}" /> |
|||
<Setter Property="Padding" Value="{DynamicResource ButtonPadding}" /> |
|||
<Setter Property="MinHeight" Value="{DynamicResource DropDownButtonMinHeight}" /> |
|||
<Setter Property="HorizontalAlignment" Value="Left" /> |
|||
<Setter Property="VerticalAlignment" Value="Center" /> |
|||
<Setter Property="HorizontalContentAlignment" Value="Stretch" /> |
|||
<Setter Property="VerticalContentAlignment" Value="Center" /> |
|||
<!--<Setter Property="UseSystemFocusVisuals" Value="{StaticResource UseSystemFocusVisuals}" /> |
|||
<Setter Property="FocusVisualMargin" Value="-3" />--> |
|||
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" /> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate> |
|||
<Border x:Name="RootBorder" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
CornerRadius="{TemplateBinding CornerRadius}" |
|||
ClipToBounds="True"> |
|||
<Grid x:Name="InnerGrid"> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="*" /> |
|||
<ColumnDefinition Width="Auto" /> |
|||
</Grid.ColumnDefinitions> |
|||
|
|||
<ContentPresenter x:Name="PART_ContentPresenter" |
|||
Grid.Column="0" |
|||
Content="{TemplateBinding Content}" |
|||
ContentTemplate="{TemplateBinding ContentTemplate}" |
|||
Padding="{TemplateBinding Padding}" |
|||
RecognizesAccessKey="True" |
|||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" |
|||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" /> |
|||
|
|||
<PathIcon x:Name="DropDownGlyph" |
|||
Grid.Column="1" |
|||
UseLayoutRounding="False" |
|||
IsHitTestVisible="False" |
|||
Height="12" |
|||
Width="12" |
|||
Margin="0,0,10,0" |
|||
HorizontalAlignment="Right" |
|||
VerticalAlignment="Center" /> |
|||
|
|||
</Grid> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<!-- Normal State --> |
|||
<Style Selector="DropDownButton /template/ PathIcon#DropDownGlyph"> |
|||
<Setter Property="Foreground" Value="{DynamicResource ComboBoxDropDownGlyphForeground}" /> |
|||
<Setter Property="Data" Value="M1939 486L2029 576L1024 1581L19 576L109 486L1024 1401L1939 486Z" /> |
|||
</Style> |
|||
|
|||
<!-- PointerOver State --> |
|||
<Style Selector="DropDownButton:pointerover /template/ Border#RootBorder"> |
|||
<Setter Property="Background" Value="{DynamicResource ButtonBackgroundPointerOver}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushPointerOver}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ButtonForegroundPointerOver}" /> |
|||
</Style> |
|||
|
|||
<!-- Pressed State --> |
|||
<Style Selector="DropDownButton:pressed /template/ Border#RootBorder"> |
|||
<Setter Property="Background" Value="{DynamicResource ButtonBackgroundPressed}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushPressed}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ButtonForegroundPressed}" /> |
|||
</Style> |
|||
|
|||
<!-- Disabled State --> |
|||
<Style Selector="DropDownButton:disabled /template/ Border#RootBorder"> |
|||
<Setter Property="Background" Value="{DynamicResource ButtonBackgroundDisabled}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushDisabled}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ButtonForegroundDisabled}" /> |
|||
</Style> |
|||
<Style Selector="DropDownButton:disabled /template/ PathIcon#DropDownGlyph"> |
|||
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundDisabled}" /> |
|||
</Style> |
|||
|
|||
</Styles> |
|||
Loading…
Reference in new issue