feat: add avalonia basic NumericUpDown style.
This commit is contained in:
1 parent
35d706d202
commit
d192cdbf8f
10 files changed
+344
-71
No files matched your search
@@ -13,6 +13,7 @@
|
||||
[ "ScrollViewer", "NativeScrollViewerDemo", "Brush.ScrollBox", "", "" ],
|
||||
[ "Slider", "SliderDemo", "Brush.Slider", "", "" ],
|
||||
[ "TextBlock", "TextBlockDemo", "Brush.TextBlock", "", "" ],
|
||||
[ "NumericUpDown", "NumericUpDownDemo", "Brush.NumericListBox", "", "" ],
|
||||
[ "TextBox", "TextBoxDemo", "Brush.TextBox", "", "" ],
|
||||
[ "ComboBox", "NativeComboBoxDemo", "Brush.ComboBox", "", "" ],
|
||||
[ "Expander", "ExpanderDemo", "Brush.Expander", "", "" ],
|
||||
@@ -49,13 +50,9 @@
|
||||
[ "ButtonGroup", "ButtonGroupDemo", "Brush.ButtonGroup", "", "Button" ],
|
||||
[ "ProgressButton", "ProgressButtonDemo", "Brush.ProgressBarStatusBar8", "", "Button" ],
|
||||
[ "Poptip", "PoptipDemo", "Brush.ToolTip", "", "DataDisplay" ],
|
||||
[ "NumericUpDown", "NumericUpDownDemo", "Brush.NumericListBox", "", "DataEntry" ],
|
||||
[ "TextBox", "TextBoxDemo", "Brush.TextBox", "", "DataEntry" ],
|
||||
[ "ComboBox", "ComboBoxDemo", "Brush.ComboBox", "", "DataEntry" ],
|
||||
[ "CheckComboBox", "CheckComboBoxDemo", "Brush.CheckBoxList", "", "DataEntry" ],
|
||||
[ "AutoCompleteTextBox", "AutoCompleteTextBoxDemo", "Brush.AutoComplete", "1", "DataEntry" ],
|
||||
[ "PinBox", "PinBoxDemo", "Brush.Ellipsis", "", "DataEntry" ],
|
||||
[ "DatePicker", "DatePickerDemo", "Brush.DateTimePicker", "", "DataEntry" ],
|
||||
[ "Clock", "ClockDemo", "Brush.Time", "", "DataEntry" ],
|
||||
[ "TimePicker", "TimePickerDemo", "Brush.TimePicker", "", "DataEntry" ],
|
||||
[ "CalendarWithClock", "CalendarWithClockDemo", "Brush.Calendar", "", "DataEntry" ],
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:vm="clr-namespace:HandyControlDemo.ViewModel"
|
||||
x:Class="HandyControlDemo.UserControl.NumericUpDownDemo"
|
||||
DataContext="{Binding InputElementDemo, Source={x:Static vm:ViewModelLocator.Instance}}">
|
||||
<ScrollViewer>
|
||||
<hc:UniformSpacingPanel Spacing="32"
|
||||
Margin="32"
|
||||
ChildWrapping="Wrap">
|
||||
<hc:UniformSpacingPanel Spacing="16"
|
||||
Orientation="Vertical">
|
||||
<NumericUpDown Value="0"
|
||||
Width="380"
|
||||
Maximum="100" />
|
||||
<NumericUpDown Value="0"
|
||||
IsEnabled="False" />
|
||||
<NumericUpDown Value="0"
|
||||
IsReadOnly="True" />
|
||||
</hc:UniformSpacingPanel>
|
||||
</hc:UniformSpacingPanel>
|
||||
</ScrollViewer>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace HandyControlDemo.UserControl;
|
||||
|
||||
public partial class NumericUpDownDemo : Avalonia.Controls.UserControl
|
||||
{
|
||||
public NumericUpDownDemo()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:hc="clr-namespace:HandyControl.Controls"
|
||||
xmlns:system="clr-namespace:System;assembly=System.Runtime">
|
||||
<ControlTheme x:Key="{x:Type ButtonSpinner}"
|
||||
TargetType="ButtonSpinner">
|
||||
<Setter Property="hc:BorderElement.CornerRadius"
|
||||
Value="{StaticResource DefaultCornerRadius}" />
|
||||
<Setter Property="CornerRadius"
|
||||
Value="{Binding $self.(hc:BorderElement.CornerRadius)}" />
|
||||
<Setter Property="MinHeight"
|
||||
Value="{StaticResource DefaultControlHeight}" />
|
||||
<Setter Property="Padding"
|
||||
Value="{StaticResource DefaultInputPadding}" />
|
||||
<Setter Property="VerticalContentAlignment"
|
||||
Value="Center" />
|
||||
<Setter Property="HorizontalContentAlignment"
|
||||
Value="Left" />
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource RegionBrush}" />
|
||||
<Setter Property="BorderBrush"
|
||||
Value="{DynamicResource BorderBrush}" />
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource PrimaryTextBrush}" />
|
||||
<Setter Property="BorderThickness"
|
||||
Value="1" />
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<DataValidationErrors>
|
||||
<Panel>
|
||||
<Border Name="border"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalAlignment}"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}" />
|
||||
<DockPanel>
|
||||
<UniformGrid Name="PART_SpinnerPanel"
|
||||
TabIndex="2"
|
||||
DockPanel.Dock="Right"
|
||||
IsVisible="{TemplateBinding ShowButtonSpinner}"
|
||||
Rows="2">
|
||||
<RepeatButton Name="PART_IncreaseButton"
|
||||
Height="{x:Static system:Double.NaN}"
|
||||
Width="{x:Static system:Double.NaN}"
|
||||
Foreground="{TemplateBinding BorderBrush}"
|
||||
IsTabStop="{TemplateBinding IsTabStop}"
|
||||
Theme="{StaticResource RepeatButtonIcon}"
|
||||
VerticalContentAlignment="Bottom"
|
||||
VerticalAlignment="Stretch"
|
||||
Padding="{Binding Padding, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ThicknessSplitConverter}, ConverterParameter='0,0,1,0'}"
|
||||
hc:IconElement.Geometry="{StaticResource UpGeometry}"
|
||||
hc:IconElement.Height="6"
|
||||
hc:IconElement.Width="{x:Static system:Double.NaN}" />
|
||||
<RepeatButton Name="PART_DecreaseButton"
|
||||
Height="{x:Static system:Double.NaN}"
|
||||
Width="{x:Static system:Double.NaN}"
|
||||
Foreground="{TemplateBinding BorderBrush}"
|
||||
IsTabStop="{TemplateBinding IsTabStop}"
|
||||
Theme="{StaticResource RepeatButtonIcon}"
|
||||
VerticalContentAlignment="Top"
|
||||
VerticalAlignment="Stretch"
|
||||
Padding="{Binding Padding, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ThicknessSplitConverter}, ConverterParameter='0,0,1,0'}"
|
||||
hc:IconElement.Geometry="{StaticResource DownGeometry}"
|
||||
hc:IconElement.Height="6"
|
||||
hc:IconElement.Width="{x:Static system:Double.NaN}" />
|
||||
</UniformGrid>
|
||||
<ContentPresenter Name="PART_ContentPresenter"
|
||||
TabIndex="1"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}" />
|
||||
</DockPanel>
|
||||
</Panel>
|
||||
</DataValidationErrors>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
|
||||
<Style Selector="^:left">
|
||||
<Setter Property="HorizontalContentAlignment"
|
||||
Value="Right" />
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<DataValidationErrors>
|
||||
<Panel>
|
||||
<Border Name="border"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalAlignment}"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}" />
|
||||
<DockPanel>
|
||||
<UniformGrid Name="PART_SpinnerPanel"
|
||||
TabIndex="2"
|
||||
DockPanel.Dock="Left"
|
||||
IsVisible="{TemplateBinding ShowButtonSpinner}"
|
||||
Rows="2">
|
||||
<RepeatButton Name="PART_IncreaseButton"
|
||||
Height="{x:Static system:Double.NaN}"
|
||||
Width="{x:Static system:Double.NaN}"
|
||||
Foreground="{TemplateBinding BorderBrush}"
|
||||
IsTabStop="{TemplateBinding IsTabStop}"
|
||||
Theme="{StaticResource RepeatButtonIcon}"
|
||||
VerticalContentAlignment="Bottom"
|
||||
VerticalAlignment="Stretch"
|
||||
Padding="{Binding Padding, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ThicknessSplitConverter}, ConverterParameter='1,0,0,0'}"
|
||||
hc:IconElement.Geometry="{StaticResource UpGeometry}"
|
||||
hc:IconElement.Height="6"
|
||||
hc:IconElement.Width="{x:Static system:Double.NaN}" />
|
||||
<RepeatButton Name="PART_DecreaseButton"
|
||||
Height="{x:Static system:Double.NaN}"
|
||||
Width="{x:Static system:Double.NaN}"
|
||||
Foreground="{TemplateBinding BorderBrush}"
|
||||
IsTabStop="{TemplateBinding IsTabStop}"
|
||||
Theme="{StaticResource RepeatButtonIcon}"
|
||||
VerticalContentAlignment="Top"
|
||||
VerticalAlignment="Stretch"
|
||||
Padding="{Binding Padding, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ThicknessSplitConverter}, ConverterParameter='1,0,0,0'}"
|
||||
hc:IconElement.Geometry="{StaticResource DownGeometry}"
|
||||
hc:IconElement.Height="6"
|
||||
hc:IconElement.Width="{x:Static system:Double.NaN}" />
|
||||
</UniformGrid>
|
||||
<ContentPresenter Name="PART_ContentPresenter"
|
||||
TabIndex="1"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}" />
|
||||
</DockPanel>
|
||||
</Panel>
|
||||
</DataValidationErrors>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,99 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:hc="clr-namespace:HandyControl.Controls"
|
||||
xmlns:system="clr-namespace:System;assembly=System.Runtime">
|
||||
|
||||
<ControlTheme x:Key="NumericUpDownBaseStyle"
|
||||
TargetType="NumericUpDown">
|
||||
<Setter Property="hc:TitleElement.MarginOnTheLeft"
|
||||
Value="0,7,6,0" />
|
||||
<Setter Property="hc:TitleElement.MarginOnTheTop"
|
||||
Value="8,0,0,5" />
|
||||
<Setter Property="hc:TitleElement.HorizontalAlignment"
|
||||
Value="Left" />
|
||||
<Setter Property="hc:BorderElement.CornerRadius"
|
||||
Value="{StaticResource DefaultCornerRadius}" />
|
||||
<Setter Property="CornerRadius"
|
||||
Value="{Binding $self.(hc:BorderElement.CornerRadius)}" />
|
||||
<Setter Property="MinHeight"
|
||||
Value="{StaticResource DefaultControlHeight}" />
|
||||
<Setter Property="Padding"
|
||||
Value="{StaticResource DefaultInputPadding}" />
|
||||
<Setter Property="VerticalContentAlignment"
|
||||
Value="Center" />
|
||||
<Setter Property="HorizontalContentAlignment"
|
||||
Value="Left" />
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource RegionBrush}" />
|
||||
<Setter Property="BorderBrush"
|
||||
Value="{DynamicResource BorderBrush}" />
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource PrimaryTextBrush}" />
|
||||
<Setter Property="BorderThickness"
|
||||
Value="1" />
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<DataValidationErrors>
|
||||
<ButtonSpinner Name="PART_Spinner"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
VerticalContentAlignment="Stretch"
|
||||
IsTabStop="False"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
MinWidth="0"
|
||||
AllowSpin="{TemplateBinding AllowSpin}"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
ButtonSpinnerLocation="{TemplateBinding ButtonSpinnerLocation}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}"
|
||||
ShowButtonSpinner="{TemplateBinding ShowButtonSpinner}">
|
||||
<TextBox Name="PART_TextBox"
|
||||
Background="Transparent"
|
||||
BorderBrush="Transparent"
|
||||
BorderThickness="0"
|
||||
Padding="0"
|
||||
MinWidth="0"
|
||||
Foreground="{TemplateBinding Foreground}"
|
||||
Watermark="{TemplateBinding Watermark}"
|
||||
IsReadOnly="{TemplateBinding IsReadOnly}"
|
||||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
Text="{TemplateBinding Text}"
|
||||
TextAlignment="{TemplateBinding TextAlignment}"
|
||||
AcceptsReturn="False"
|
||||
TextWrapping="NoWrap" />
|
||||
</ButtonSpinner>
|
||||
</DataValidationErrors>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
|
||||
<Style Selector="^:disabled">
|
||||
<Setter Property="Opacity"
|
||||
Value="0.4" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:pointerover /template/ ButtonSpinner#PART_Spinner">
|
||||
<Setter Property="BorderBrush"
|
||||
Value="{DynamicResource SecondaryBorderBrush}" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:focus-within">
|
||||
<Style Selector="^:pointerover /template/ ButtonSpinner#PART_Spinner">
|
||||
<Setter Property="BorderBrush"
|
||||
Value="{DynamicResource PrimaryBrush}" />
|
||||
</Style>
|
||||
<Setter Property="BorderBrush"
|
||||
Value="{DynamicResource PrimaryBrush}" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:error /template/ ButtonSpinner#PART_Spinner">
|
||||
<Setter Property="BorderBrush"
|
||||
Value="{DynamicResource DangerBrush}" />
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="{x:Type NumericUpDown}"
|
||||
BasedOn="{StaticResource NumericUpDownBaseStyle}"
|
||||
TargetType="NumericUpDown" />
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -39,43 +39,45 @@
|
||||
Value="True" />
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<Panel>
|
||||
<Border x:Name="border"
|
||||
CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Background="{TemplateBinding Background}" />
|
||||
<ScrollViewer Name="PART_ScrollViewer"
|
||||
AllowAutoHide="{TemplateBinding (ScrollViewer.AllowAutoHide)}"
|
||||
BringIntoViewOnFocusChange="{TemplateBinding (ScrollViewer.BringIntoViewOnFocusChange)}"
|
||||
HorizontalScrollBarVisibility="{TemplateBinding (ScrollViewer.HorizontalScrollBarVisibility)}"
|
||||
IsScrollChainingEnabled="{TemplateBinding (ScrollViewer.IsScrollChainingEnabled)}"
|
||||
VerticalScrollBarVisibility="{TemplateBinding (ScrollViewer.VerticalScrollBarVisibility)}">
|
||||
<TextPresenter Name="PART_TextPresenter"
|
||||
Margin="{TemplateBinding Padding}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
CaretBlinkInterval="{TemplateBinding CaretBlinkInterval}"
|
||||
CaretBrush="{TemplateBinding CaretBrush}"
|
||||
CaretIndex="{TemplateBinding CaretIndex}"
|
||||
LineHeight="{TemplateBinding LineHeight}"
|
||||
LetterSpacing="{TemplateBinding LetterSpacing}"
|
||||
PasswordChar="{TemplateBinding PasswordChar}"
|
||||
RevealPassword="{TemplateBinding RevealPassword}"
|
||||
SelectionBrush="{TemplateBinding SelectionBrush}"
|
||||
SelectionEnd="{TemplateBinding SelectionEnd}"
|
||||
SelectionForegroundBrush="{TemplateBinding SelectionForegroundBrush}"
|
||||
SelectionStart="{TemplateBinding SelectionStart}"
|
||||
Text="{TemplateBinding Text,Mode=TwoWay}"
|
||||
TextAlignment="{TemplateBinding TextAlignment}"
|
||||
TextWrapping="{TemplateBinding TextWrapping}" />
|
||||
<ScrollViewer.Styles>
|
||||
<Style Selector="ScrollContentPresenter#PART_ContentPresenter">
|
||||
<Setter Property="Cursor"
|
||||
Value="IBeam" />
|
||||
</Style>
|
||||
</ScrollViewer.Styles>
|
||||
</ScrollViewer>
|
||||
</Panel>
|
||||
<DataValidationErrors>
|
||||
<Panel>
|
||||
<Border x:Name="border"
|
||||
CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Background="{TemplateBinding Background}" />
|
||||
<ScrollViewer Name="PART_ScrollViewer"
|
||||
AllowAutoHide="{TemplateBinding (ScrollViewer.AllowAutoHide)}"
|
||||
BringIntoViewOnFocusChange="{TemplateBinding (ScrollViewer.BringIntoViewOnFocusChange)}"
|
||||
HorizontalScrollBarVisibility="{TemplateBinding (ScrollViewer.HorizontalScrollBarVisibility)}"
|
||||
IsScrollChainingEnabled="{TemplateBinding (ScrollViewer.IsScrollChainingEnabled)}"
|
||||
VerticalScrollBarVisibility="{TemplateBinding (ScrollViewer.VerticalScrollBarVisibility)}">
|
||||
<TextPresenter Name="PART_TextPresenter"
|
||||
Margin="{TemplateBinding Padding}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
CaretBlinkInterval="{TemplateBinding CaretBlinkInterval}"
|
||||
CaretBrush="{TemplateBinding CaretBrush}"
|
||||
CaretIndex="{TemplateBinding CaretIndex}"
|
||||
LineHeight="{TemplateBinding LineHeight}"
|
||||
LetterSpacing="{TemplateBinding LetterSpacing}"
|
||||
PasswordChar="{TemplateBinding PasswordChar}"
|
||||
RevealPassword="{TemplateBinding RevealPassword}"
|
||||
SelectionBrush="{TemplateBinding SelectionBrush}"
|
||||
SelectionEnd="{TemplateBinding SelectionEnd}"
|
||||
SelectionForegroundBrush="{TemplateBinding SelectionForegroundBrush}"
|
||||
SelectionStart="{TemplateBinding SelectionStart}"
|
||||
Text="{TemplateBinding Text,Mode=TwoWay}"
|
||||
TextAlignment="{TemplateBinding TextAlignment}"
|
||||
TextWrapping="{TemplateBinding TextWrapping}" />
|
||||
<ScrollViewer.Styles>
|
||||
<Style Selector="ScrollContentPresenter#PART_ContentPresenter">
|
||||
<Setter Property="Cursor"
|
||||
Value="IBeam" />
|
||||
</Style>
|
||||
</ScrollViewer.Styles>
|
||||
</ScrollViewer>
|
||||
</Panel>
|
||||
</DataValidationErrors>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
<MergeResourceInclude Source="/Themes/Styles/ProgressBar.axaml" />
|
||||
<MergeResourceInclude Source="/Themes/Styles/Calendar.axaml" />
|
||||
<MergeResourceInclude Source="/Themes/Styles/TextBox.axaml" />
|
||||
<MergeResourceInclude Source="/Themes/Styles/ButtonSpinner.axaml" />
|
||||
<MergeResourceInclude Source="/Themes/Styles/NumericUpDown.axaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Styles.Resources>
|
||||
|
||||
Reference in new issue
Block a user