From 9684dce56bc86922f71f5f83f53d0d1e2a068261 Mon Sep 17 00:00:00 2001 From: heartacker Date: Wed, 20 Mar 2024 20:29:15 +0800 Subject: [PATCH] add new demo view which can change the property --- demo/Ursa.Demo/Pages/NumericUpDownDemo.axaml | 176 ++++++++++++++++-- .../Pages/NumericUpDownDemo.axaml.cs | 10 + .../ViewModels/NumericUpDownDemoViewModel.cs | 48 ++++- .../Controls/NumericUpDown.axaml | 1 - 4 files changed, 220 insertions(+), 15 deletions(-) diff --git a/demo/Ursa.Demo/Pages/NumericUpDownDemo.axaml b/demo/Ursa.Demo/Pages/NumericUpDownDemo.axaml index afe4496..14336ac 100644 --- a/demo/Ursa.Demo/Pages/NumericUpDownDemo.axaml +++ b/demo/Ursa.Demo/Pages/NumericUpDownDemo.axaml @@ -8,19 +8,173 @@ d:DesignHeight="450" d:DesignWidth="800" mc:Ignorable="d"> + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demo/Ursa.Demo/Pages/NumericUpDownDemo.axaml.cs b/demo/Ursa.Demo/Pages/NumericUpDownDemo.axaml.cs index 4bdf06d..8ca1387 100644 --- a/demo/Ursa.Demo/Pages/NumericUpDownDemo.axaml.cs +++ b/demo/Ursa.Demo/Pages/NumericUpDownDemo.axaml.cs @@ -1,6 +1,9 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; +using System; +using System.Diagnostics; +using Ursa.Controls; using Ursa.Demo.ViewModels; namespace Ursa.Demo.Pages; @@ -11,5 +14,12 @@ public partial class NumericUpDownDemo : UserControl { InitializeComponent(); DataContext = new NumericUpDownDemoViewModel(); + numd.ValueChanged += Numd_ValueChanged; + } + + private void Numd_ValueChanged(object? sender, ValueChangedEventArgs e) + { + Trace.WriteLine($"{(sender as NumericUIntUpDown).Name} {e.OldValue} {e.NewValue}"); + } } \ No newline at end of file diff --git a/demo/Ursa.Demo/ViewModels/NumericUpDownDemoViewModel.cs b/demo/Ursa.Demo/ViewModels/NumericUpDownDemoViewModel.cs index 9840cca..cd229ae 100644 --- a/demo/Ursa.Demo/ViewModels/NumericUpDownDemoViewModel.cs +++ b/demo/Ursa.Demo/ViewModels/NumericUpDownDemoViewModel.cs @@ -1,8 +1,50 @@ -using CommunityToolkit.Mvvm.ComponentModel; +using Avalonia.Controls; +using Avalonia.Layout; +using CommunityToolkit.Mvvm.ComponentModel; +using System; +using System.Globalization; +using Ursa.Controls; +using static System.Runtime.InteropServices.JavaScript.JSType; namespace Ursa.Demo.ViewModels; -public class NumericUpDownDemoViewModel: ObservableObject +public partial class NumericUpDownDemoViewModel : ObservableObject { - + + [ObservableProperty] private uint _Value; + [ObservableProperty] private string _FontFamily = "Consolas"; + [ObservableProperty] private bool _AllowDrag = false; + [ObservableProperty] private bool _IsReadOnly = false; + + [ObservableProperty] private Array _Array_HorizontalContentAlignment; + [ObservableProperty] private HorizontalAlignment _HorizontalContentAlignment = HorizontalAlignment.Center; + [ObservableProperty] private object? _InnerLeftContent = "obj:0x"; + [ObservableProperty] private string _Watermark = "Water mark showed"; + [ObservableProperty] private string _FormatString = "x8"; + [ObservableProperty] private Array _Array_ParsingNumberStyle; + [ObservableProperty] private NumberStyles _ParsingNumberStyle = NumberStyles.AllowHexSpecifier; + [ObservableProperty] private bool _AllowSpin = true; + [ObservableProperty] private bool _ShowButtonSpinner = true; + + [ObservableProperty] private UInt32 _Maximum = UInt32.MaxValue; + [ObservableProperty] private UInt32 _Minimum = UInt32.MinValue; + [ObservableProperty] private UInt32 _Step = 1; + + [ObservableProperty] private bool _IsEnable = true; + + + public NumericUpDownDemoViewModel() + { + Array_HorizontalContentAlignment = Enum.GetValues(typeof(HorizontalAlignment)); + Array_ParsingNumberStyle = Enum.GetValues(typeof(NumberStyles)); + NumericUIntUpDown numericUIntUpDown; + TextBox textBox; + + } + + partial void OnValueChanging(uint oldValue, uint newValue) + { + Console.WriteLine(oldValue); + } + } \ No newline at end of file diff --git a/src/Ursa.Themes.Semi/Controls/NumericUpDown.axaml b/src/Ursa.Themes.Semi/Controls/NumericUpDown.axaml index 11c4b6b..f9533e5 100644 --- a/src/Ursa.Themes.Semi/Controls/NumericUpDown.axaml +++ b/src/Ursa.Themes.Semi/Controls/NumericUpDown.axaml @@ -55,7 +55,6 @@ InnerLeftContent="{TemplateBinding InnerLeftContent}" IsReadOnly="{TemplateBinding IsReadOnly}" TextWrapping="NoWrap" - InnerLeftContent="{TemplateBinding InnerLeftContent}" Theme="{DynamicResource NonErrorTextBox}" Watermark="{TemplateBinding Watermark}" />