Merge pull request #366 from irihitech/issue/363
NumericUpDown family updates
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:u="https://irihi.tech/ursa"
|
xmlns:u="https://irihi.tech/ursa"
|
||||||
xmlns:vm="using:Ursa.Demo.ViewModels"
|
xmlns:vm="using:Ursa.Demo.ViewModels"
|
||||||
|
xmlns:system="clr-namespace:System;assembly=System.Runtime"
|
||||||
d:DesignHeight="450"
|
d:DesignHeight="450"
|
||||||
d:DesignWidth="800"
|
d:DesignWidth="800"
|
||||||
x:CompileBindings="True"
|
x:CompileBindings="True"
|
||||||
@@ -34,6 +35,7 @@
|
|||||||
FontFamily="{Binding FontFamily, Mode=OneWay}"
|
FontFamily="{Binding FontFamily, Mode=OneWay}"
|
||||||
FormatString="{Binding FormatString}"
|
FormatString="{Binding FormatString}"
|
||||||
InnerLeftContent="{Binding InnerLeftContent}"
|
InnerLeftContent="{Binding InnerLeftContent}"
|
||||||
|
InnerRightContent="{Binding InnerRightContent}"
|
||||||
IsEnabled="{Binding IsEnable}"
|
IsEnabled="{Binding IsEnable}"
|
||||||
IsReadOnly="{Binding IsReadOnly}"
|
IsReadOnly="{Binding IsReadOnly}"
|
||||||
Maximum="{Binding Maximum}"
|
Maximum="{Binding Maximum}"
|
||||||
@@ -125,6 +127,24 @@
|
|||||||
Step="1"
|
Step="1"
|
||||||
Watermark="AllowHexSpecifier"
|
Watermark="AllowHexSpecifier"
|
||||||
Value="2" />
|
Value="2" />
|
||||||
|
<u:Divider Content="Sizes" />
|
||||||
|
<u:NumericUIntUpDown
|
||||||
|
Classes="Small"
|
||||||
|
Step="1"
|
||||||
|
Watermark="Small"/>
|
||||||
|
<u:NumericUIntUpDown
|
||||||
|
Classes="Large"
|
||||||
|
Step="1"
|
||||||
|
Margin="0 8 0 0"
|
||||||
|
Watermark="Large"/>
|
||||||
|
<u:Divider Content="Error" />
|
||||||
|
<u:NumericUIntUpDown
|
||||||
|
Step="1"
|
||||||
|
Watermark="Validation Error">
|
||||||
|
<DataValidationErrors.Error>
|
||||||
|
<system:Exception/>
|
||||||
|
</DataValidationErrors.Error>
|
||||||
|
</u:NumericUIntUpDown>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ public partial class NumericUpDownDemoViewModel : ObservableObject
|
|||||||
[ObservableProperty] private Array _arrayHorizontalContentAlignment;
|
[ObservableProperty] private Array _arrayHorizontalContentAlignment;
|
||||||
[ObservableProperty] private HorizontalAlignment _horizontalContentAlignment = HorizontalAlignment.Center;
|
[ObservableProperty] private HorizontalAlignment _horizontalContentAlignment = HorizontalAlignment.Center;
|
||||||
[ObservableProperty] private object? _innerLeftContent = "obj:0x";
|
[ObservableProperty] private object? _innerLeftContent = "obj:0x";
|
||||||
|
[ObservableProperty] private object? _innerRightContent = "%";
|
||||||
[ObservableProperty] private string _watermark = "Water mark showed";
|
[ObservableProperty] private string _watermark = "Water mark showed";
|
||||||
[ObservableProperty] private string _formatString = "X8";
|
[ObservableProperty] private string _formatString = "X8";
|
||||||
[ObservableProperty] private Array _arrayParsingNumberStyle;
|
[ObservableProperty] private Array _arrayParsingNumberStyle;
|
||||||
|
|||||||
@@ -57,9 +57,10 @@
|
|||||||
Margin="0,0,8,0"
|
Margin="0,0,8,0"
|
||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
Command="{Binding $parent[u:KeyGestureInput].Clear}"
|
Command="{Binding $parent[u:KeyGestureInput].Clear}"
|
||||||
|
Content="{DynamicResource IconButtonClearData}"
|
||||||
Focusable="False"
|
Focusable="False"
|
||||||
IsVisible="False"
|
IsVisible="False"
|
||||||
Theme="{DynamicResource InputClearButton}" />
|
Theme="{DynamicResource InnerIconButton}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Panel>
|
</Panel>
|
||||||
</Border>
|
</Border>
|
||||||
|
|||||||
@@ -4,29 +4,9 @@
|
|||||||
xmlns:u="https://irihi.tech/ursa">
|
xmlns:u="https://irihi.tech/ursa">
|
||||||
<!-- Add Resources Here -->
|
<!-- Add Resources Here -->
|
||||||
|
|
||||||
<ControlTheme x:Key="InputClearButton" TargetType="Button">
|
|
||||||
<Setter Property="Button.Foreground" Value="{DynamicResource TextBoxButtonDefaultForeground}" />
|
|
||||||
<Setter Property="Button.Cursor" Value="Hand" />
|
|
||||||
<Setter Property="Button.Template">
|
|
||||||
<ControlTemplate TargetType="Button">
|
|
||||||
<!-- Background must be transparent or hit test will fail -->
|
|
||||||
<ContentControl Background="Transparent">
|
|
||||||
<PathIcon
|
|
||||||
Width="16"
|
|
||||||
Height="16"
|
|
||||||
Data="{DynamicResource TextBoxClearButtonData}"
|
|
||||||
Foreground="{TemplateBinding Foreground}" />
|
|
||||||
</ContentControl>
|
|
||||||
</ControlTemplate>
|
|
||||||
</Setter>
|
|
||||||
<Style Selector="^:pointerover">
|
|
||||||
<Setter Property="Foreground" Value="{DynamicResource TextBoxButtonPointeroverForeground}" />
|
|
||||||
</Style>
|
|
||||||
</ControlTheme>
|
|
||||||
|
|
||||||
<ControlTheme x:Key="{x:Type u:NumericUpDown}" TargetType="{x:Type u:NumericUpDown}">
|
<ControlTheme x:Key="{x:Type u:NumericUpDown}" TargetType="{x:Type u:NumericUpDown}">
|
||||||
<Setter Property="CornerRadius" Value="{DynamicResource NumericUpDownCornerRadius}" />
|
<Setter Property="CornerRadius" Value="{DynamicResource NumericUpDownCornerRadius}" />
|
||||||
<Setter Property="MinHeight" Value="{DynamicResource NumericUpDownDefaultHeight}"></Setter>
|
<Setter Property="MinHeight" Value="{DynamicResource NumericUpDownDefaultHeight}" />
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<ControlTemplate TargetType="u:NumericUpDown">
|
<ControlTemplate TargetType="u:NumericUpDown">
|
||||||
<DataValidationErrors>
|
<DataValidationErrors>
|
||||||
@@ -52,6 +32,7 @@
|
|||||||
FontSize="{TemplateBinding FontSize}"
|
FontSize="{TemplateBinding FontSize}"
|
||||||
Foreground="{TemplateBinding Foreground}"
|
Foreground="{TemplateBinding Foreground}"
|
||||||
InnerLeftContent="{TemplateBinding InnerLeftContent}"
|
InnerLeftContent="{TemplateBinding InnerLeftContent}"
|
||||||
|
InnerRightContent="{TemplateBinding InnerRightContent}"
|
||||||
TextWrapping="NoWrap"
|
TextWrapping="NoWrap"
|
||||||
Theme="{DynamicResource NonErrorTextBox}"
|
Theme="{DynamicResource NonErrorTextBox}"
|
||||||
Watermark="{TemplateBinding Watermark}" />
|
Watermark="{TemplateBinding Watermark}" />
|
||||||
@@ -68,7 +49,8 @@
|
|||||||
Command="{Binding $parent[u:NumericUpDown].Clear}"
|
Command="{Binding $parent[u:NumericUpDown].Clear}"
|
||||||
Focusable="False"
|
Focusable="False"
|
||||||
IsVisible="False"
|
IsVisible="False"
|
||||||
Theme="{StaticResource InputClearButton}" />
|
Content="{DynamicResource IconButtonClearData}"
|
||||||
|
Theme="{DynamicResource InnerIconButton}" />
|
||||||
</Panel>
|
</Panel>
|
||||||
</ButtonSpinner>
|
</ButtonSpinner>
|
||||||
</DataValidationErrors>
|
</DataValidationErrors>
|
||||||
@@ -83,5 +65,12 @@
|
|||||||
<Setter Property="IsVisible" Value="True" />
|
<Setter Property="IsVisible" Value="True" />
|
||||||
</Style>
|
</Style>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="^.Large">
|
||||||
|
<Setter Property="MinHeight" Value="{DynamicResource NumericUpDownLargeHeight}" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="^.Small">
|
||||||
|
<Setter Property="MinHeight" Value="{DynamicResource NumericUpDownSmallHeight}" />
|
||||||
|
</Style>
|
||||||
</ControlTheme>
|
</ControlTheme>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace Ursa.Controls;
|
|||||||
[TemplatePart(PART_Spinner, typeof(ButtonSpinner))]
|
[TemplatePart(PART_Spinner, typeof(ButtonSpinner))]
|
||||||
[TemplatePart(PART_TextBox, typeof(TextBox))]
|
[TemplatePart(PART_TextBox, typeof(TextBox))]
|
||||||
[TemplatePart(PART_DragPanel, typeof(Panel))]
|
[TemplatePart(PART_DragPanel, typeof(Panel))]
|
||||||
public abstract class NumericUpDown : TemplatedControl, IClearControl
|
public abstract class NumericUpDown : TemplatedControl, IClearControl, IInnerContentControl
|
||||||
{
|
{
|
||||||
public const string PART_Spinner = "PART_Spinner";
|
public const string PART_Spinner = "PART_Spinner";
|
||||||
public const string PART_TextBox = "PART_TextBox";
|
public const string PART_TextBox = "PART_TextBox";
|
||||||
@@ -62,8 +62,9 @@ public abstract class NumericUpDown : TemplatedControl, IClearControl
|
|||||||
set => SetValue(HorizontalContentAlignmentProperty, value);
|
set => SetValue(HorizontalContentAlignmentProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly StyledProperty<object?> InnerLeftContentProperty = AvaloniaProperty.Register<NumericUpDown, object?>(
|
public static readonly StyledProperty<object?> InnerLeftContentProperty =
|
||||||
nameof(InnerLeftContent));
|
AvaloniaProperty.Register<NumericUpDown, object?>(
|
||||||
|
nameof(InnerLeftContent));
|
||||||
|
|
||||||
public object? InnerLeftContent
|
public object? InnerLeftContent
|
||||||
{
|
{
|
||||||
@@ -71,6 +72,16 @@ public abstract class NumericUpDown : TemplatedControl, IClearControl
|
|||||||
set => SetValue(InnerLeftContentProperty, value);
|
set => SetValue(InnerLeftContentProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static readonly StyledProperty<object?> InnerRightContentProperty =
|
||||||
|
AvaloniaProperty.Register<NumericUpDown, object?>(
|
||||||
|
nameof(InnerRightContent));
|
||||||
|
|
||||||
|
public object? InnerRightContent
|
||||||
|
{
|
||||||
|
get => GetValue(InnerRightContentProperty);
|
||||||
|
set => SetValue(InnerRightContentProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
public static readonly StyledProperty<string?> WatermarkProperty = AvaloniaProperty.Register<NumericUpDown, string?>(
|
public static readonly StyledProperty<string?> WatermarkProperty = AvaloniaProperty.Register<NumericUpDown, string?>(
|
||||||
nameof(Watermark));
|
nameof(Watermark));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user