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:u="https://irihi.tech/ursa"
|
||||
xmlns:vm="using:Ursa.Demo.ViewModels"
|
||||
xmlns:system="clr-namespace:System;assembly=System.Runtime"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
x:CompileBindings="True"
|
||||
@@ -34,6 +35,7 @@
|
||||
FontFamily="{Binding FontFamily, Mode=OneWay}"
|
||||
FormatString="{Binding FormatString}"
|
||||
InnerLeftContent="{Binding InnerLeftContent}"
|
||||
InnerRightContent="{Binding InnerRightContent}"
|
||||
IsEnabled="{Binding IsEnable}"
|
||||
IsReadOnly="{Binding IsReadOnly}"
|
||||
Maximum="{Binding Maximum}"
|
||||
@@ -125,6 +127,24 @@
|
||||
Step="1"
|
||||
Watermark="AllowHexSpecifier"
|
||||
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>
|
||||
</Grid>
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ public partial class NumericUpDownDemoViewModel : ObservableObject
|
||||
[ObservableProperty] private Array _arrayHorizontalContentAlignment;
|
||||
[ObservableProperty] private HorizontalAlignment _horizontalContentAlignment = HorizontalAlignment.Center;
|
||||
[ObservableProperty] private object? _innerLeftContent = "obj:0x";
|
||||
[ObservableProperty] private object? _innerRightContent = "%";
|
||||
[ObservableProperty] private string _watermark = "Water mark showed";
|
||||
[ObservableProperty] private string _formatString = "X8";
|
||||
[ObservableProperty] private Array _arrayParsingNumberStyle;
|
||||
|
||||
@@ -57,9 +57,10 @@
|
||||
Margin="0,0,8,0"
|
||||
HorizontalAlignment="Right"
|
||||
Command="{Binding $parent[u:KeyGestureInput].Clear}"
|
||||
Content="{DynamicResource IconButtonClearData}"
|
||||
Focusable="False"
|
||||
IsVisible="False"
|
||||
Theme="{DynamicResource InputClearButton}" />
|
||||
Theme="{DynamicResource InnerIconButton}" />
|
||||
</Grid>
|
||||
</Panel>
|
||||
</Border>
|
||||
|
||||
@@ -4,29 +4,9 @@
|
||||
xmlns:u="https://irihi.tech/ursa">
|
||||
<!-- 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}">
|
||||
<Setter Property="CornerRadius" Value="{DynamicResource NumericUpDownCornerRadius}" />
|
||||
<Setter Property="MinHeight" Value="{DynamicResource NumericUpDownDefaultHeight}"></Setter>
|
||||
<Setter Property="MinHeight" Value="{DynamicResource NumericUpDownDefaultHeight}" />
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="u:NumericUpDown">
|
||||
<DataValidationErrors>
|
||||
@@ -52,6 +32,7 @@
|
||||
FontSize="{TemplateBinding FontSize}"
|
||||
Foreground="{TemplateBinding Foreground}"
|
||||
InnerLeftContent="{TemplateBinding InnerLeftContent}"
|
||||
InnerRightContent="{TemplateBinding InnerRightContent}"
|
||||
TextWrapping="NoWrap"
|
||||
Theme="{DynamicResource NonErrorTextBox}"
|
||||
Watermark="{TemplateBinding Watermark}" />
|
||||
@@ -68,7 +49,8 @@
|
||||
Command="{Binding $parent[u:NumericUpDown].Clear}"
|
||||
Focusable="False"
|
||||
IsVisible="False"
|
||||
Theme="{StaticResource InputClearButton}" />
|
||||
Content="{DynamicResource IconButtonClearData}"
|
||||
Theme="{DynamicResource InnerIconButton}" />
|
||||
</Panel>
|
||||
</ButtonSpinner>
|
||||
</DataValidationErrors>
|
||||
@@ -83,5 +65,12 @@
|
||||
<Setter Property="IsVisible" Value="True" />
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
<Style Selector="^.Large">
|
||||
<Setter Property="MinHeight" Value="{DynamicResource NumericUpDownLargeHeight}" />
|
||||
</Style>
|
||||
<Style Selector="^.Small">
|
||||
<Setter Property="MinHeight" Value="{DynamicResource NumericUpDownSmallHeight}" />
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Ursa.Controls;
|
||||
[TemplatePart(PART_Spinner, typeof(ButtonSpinner))]
|
||||
[TemplatePart(PART_TextBox, typeof(TextBox))]
|
||||
[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_TextBox = "PART_TextBox";
|
||||
@@ -62,8 +62,9 @@ public abstract class NumericUpDown : TemplatedControl, IClearControl
|
||||
set => SetValue(HorizontalContentAlignmentProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<object?> InnerLeftContentProperty = AvaloniaProperty.Register<NumericUpDown, object?>(
|
||||
nameof(InnerLeftContent));
|
||||
public static readonly StyledProperty<object?> InnerLeftContentProperty =
|
||||
AvaloniaProperty.Register<NumericUpDown, object?>(
|
||||
nameof(InnerLeftContent));
|
||||
|
||||
public object? InnerLeftContent
|
||||
{
|
||||
@@ -71,6 +72,16 @@ public abstract class NumericUpDown : TemplatedControl, IClearControl
|
||||
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?>(
|
||||
nameof(Watermark));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user