Skip to content

Commit e8680e6

Browse files
authored
Merge pull request #22 from heartacker:heartacker/issue18
更新 README.md,新增 PseudoClasses 说明及示例,更新 VariableBox 版本至 0.5.0
2 parents 1a778e9 + 3a375d2 commit e8680e6

7 files changed

Lines changed: 75 additions & 19 deletions

File tree

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ VariableBox is a Avalonia Control for building cross-platform UIs with Avalonia
3434

3535
## ChangeLog
3636

37+
- 2025/02/21(v0.5.0)
38+
1. remote property `IsEnableEditingIndicator` indicator
39+
2. please use the `PseudoClasses`
40+
1. `:editing` for editing
41+
2. `:invalid` for invalid input
42+
3743
- 2025/02/19(v0.4.0)
3844
1. fix the style of buttonspinner and the disabled style
3945
1. fluent,semi and simple is all supported
@@ -102,6 +108,38 @@ You can now use VariableBox controls in your Avalonia Application.
102108
</Window>
103109
```
104110

111+
### PseudoClasses
112+
113+
- `:editing` for editing
114+
- `:invalid` for invalid input
115+
116+
e.g.:
117+
118+
<div style="display: flex;">
119+
<div style="flex: 50%; padding: 2px;">
120+
121+
122+
```xml
123+
<Style Selector="vbox|NumericUpDown:editing">
124+
<Style Selector="^ /template/ TextBox#PART_TextBox">
125+
<Setter Property="Foreground" Value="Green" />
126+
</Style>
127+
<Style Selector="^:invalid /template/ TextBox#PART_TextBox">
128+
<Setter Property="Foreground" Value="Red" />
129+
</Style>
130+
</Style>
131+
```
132+
133+
</div>
134+
135+
<div style="flex: 20%; padding: 2px;">
136+
137+
![pseudoclass](assets/pseudoclass.png)
138+
139+
</div>
140+
</div>
141+
142+
105143
### VariableBox.Themes
106144

107145
To make VariableBox controls show up in your application, you need to reference to a theme package designed for VariableBox.

assets/pseudoclass.png

3.1 KB
Loading

demo/Ursa.Demo/Pages/NumericUpDownDemo.axaml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,19 @@
2525
<Style Selector="v|NumericUpDown:invalid">
2626
<Setter Property="Foreground" Value="red" />
2727
</Style>
28-
<!--
28+
29+
<Style Selector="v|NumericUpDown:editing">
30+
<Setter Property="FontSize" Value="15" />
31+
</Style>
32+
2933
<Style Selector="v|NumericUpDown:editing">
30-
<Setter Property="FontSize" Value="12" />
34+
<Style Selector="^ /template/ TextBox#PART_TextBox">
35+
<Setter Property="Foreground" Value="Green" />
36+
</Style>
37+
<Style Selector="^:invalid /template/ TextBox#PART_TextBox">
38+
<Setter Property="Foreground" Value="Red" />
39+
</Style>
3140
</Style>
32-
-->
3341
</UserControl.Styles>
3442

3543
<Grid ColumnDefinitions="350,auto,*" RowDefinitions="auto,*">
@@ -47,6 +55,7 @@
4755
Margin="10"
4856
HorizontalAlignment="Stretch"
4957
>
58+
<!-- IsEnableEditingIndicator="{Binding IsEnableEditingIndicator}" -->
5059
<v:VariableBoxUInt
5160
Name="numd"
5261
Width="{Binding Width}"
@@ -59,7 +68,6 @@
5968
HeaderDoubleTaped="Numd_HeaderDoubleTaped"
6069
IsAllowDrag="{Binding IsAllowDrag}"
6170
IsAllowSpin="{Binding IsAllowSpin}"
62-
IsEnableEditingIndicator="{Binding IsEnableEditingIndicator}"
6371
IsEnabled="{Binding IsEnable}"
6472
IsReadOnly="{Binding IsReadOnly}"
6573
IsShowReadButton="{Binding IsShowReadButton}"
@@ -296,7 +304,7 @@
296304

297305
<CheckBox Content="IsReadOnly" IsChecked="{Binding IsReadOnly}" />
298306
<CheckBox Content="IsUpdateValueWhenLostFocus" IsChecked="{Binding IsUpdateValueWhenLostFocus}" />
299-
<CheckBox Content="IsEnableEditingIndicator" IsChecked="{Binding IsEnableEditingIndicator}" />
307+
<!-- <CheckBox Content="IsEnableEditingIndicator" IsChecked="{Binding IsEnableEditingIndicator}" /> -->
300308
<CheckBox Content="IsShowReadButton" IsChecked="{Binding IsShowReadButton}" />
301309
<CheckBox Content="IsShowWriteButton" IsChecked="{Binding IsShowWriteButton}" />
302310

demo/Ursa.Demo/ViewModels/NumericUpDownDemoViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public partial class NumericUpDownDemoViewModel : ObservableObject
5151

5252
[ObservableProperty] private bool _IsShowReadButton = true;
5353
[ObservableProperty] private bool _IsShowWriteButton = true;
54-
[ObservableProperty] private bool _IsEnableEditingIndicator = true;
54+
// [ObservableProperty] private bool _IsEnableEditingIndicator = true;
5555

5656

5757
uint v = 0;

src/Package.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
33
<AvaloniaVersion>11.2.1</AvaloniaVersion>
4-
<VariableBoxVersion>0.4.1</VariableBoxVersion>
4+
<VariableBoxVersion>0.5.0</VariableBoxVersion>
55
</PropertyGroup>
66
</Project>

src/VariableBox/Controls/VariableBox/NumericUpDownBase.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ public bool IsUpdateValueWhenLostFocus
190190

191191
public bool IsEditingValid { get; protected set; }
192192

193+
#if false
193194
public static readonly StyledProperty<bool> IsEditingVisiableProperty =
194195
AvaloniaProperty.Register<NumericUpDown, bool>(nameof(IsEditingVisiable), false);
195196

@@ -202,6 +203,7 @@ public bool IsEditingVisiable
202203
get => GetValue(IsEditingVisiableProperty);
203204
protected set => SetValue(IsEditingVisiableProperty, value && IsEnableEditingIndicator);
204205
}
206+
#endif
205207

206208
public static readonly StyledProperty<bool> IsEditingProperty =
207209
AvaloniaProperty.Register<NumericUpDown, bool>(nameof(IsEditing), false);
@@ -237,12 +239,13 @@ static NumericUpDown()
237239
IsShowReadButtonProperty.Changed.AddClassHandler<NumericUpDown, bool>((o, e) => o.OnReadWriteShowChange(e));
238240
IsShowWriteButtonProperty.Changed.AddClassHandler<NumericUpDown, bool>((o, e) => o.OnReadWriteShowChange(e));
239241

240-
IsEnableEditingIndicatorProperty.Changed.AddClassHandler<NumericUpDown, bool>((o, e) => o.OnIsEnableEditingIndicatorChanged(e));
242+
// IsEnableEditingIndicatorProperty.Changed.AddClassHandler<NumericUpDown, bool>((o, e) => o.OnIsEnableEditingIndicatorChanged(e));
241243
}
242244

243245
private void OnIsEnableEditingIndicatorChanged(AvaloniaPropertyChangedEventArgs<bool> e)
244246
{
245-
IsEditingVisiable = IsEditing && IsEnableEditingIndicator;
247+
// IsEditingVisiable =
248+
// IsEditing && IsEnableEditingIndicator;
246249
}
247250

248251
private void OnReadWriteShowChange(AvaloniaPropertyChangedEventArgs<bool> e)
@@ -367,7 +370,8 @@ private void OnTextBoxTextChanged(object? sender, TextChangedEventArgs e)
367370
{
368371
CheckContextIsChangedAndValid((sender as TextBox).Text, ref ed, ref edv);
369372

370-
IsEditingVisiable = IsEditing = ed;
373+
// IsEditingVisiable =
374+
IsEditing = ed;
371375
IsEditingValid = edv;
372376
UpdatePseudoClasses();
373377
}

src/VariableBox/Controls/VariableBoxNumeric.axaml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@
3333
<ControlTemplate>
3434
<!-- BorderBrush="LightGray" -->
3535
<Border
36+
Name="PART_Border"
3637
Margin="{TemplateBinding Margin}"
38+
Background="{TemplateBinding Background}"
3739
BorderBrush="{TemplateBinding BorderBrush}"
3840
BorderThickness="1"
39-
Background="{TemplateBinding Background}"
4041
CornerRadius="{DynamicResource ControlCornerRadius}"
4142
>
4243
<Grid Background="Transparent" ColumnDefinitions="*,auto">
@@ -101,15 +102,15 @@
101102
Theme="{StaticResource InputClearButton}"
102103
/>
103104
-->
104-
<Label
105+
<!-- <Label
105106
Name="PART_Id_IsEditing"
106107
Margin="2,1,2,0"
107108
Background="Transparent"
108109
Content="*"
109110
Foreground="Green"
110111
IsHitTestVisible="False"
111112
IsVisible="{TemplateBinding IsEditingVisiable}"
112-
/>
113+
/>-->
113114
</Panel>
114115
</ButtonSpinner>
115116

@@ -185,7 +186,7 @@
185186
<Setter Property="Background" Value="Transparent" />
186187
<Setter Property="Opacity" Value="0.5" />
187188
</Style>
188-
</Style> -->
189+
</Style>-->
189190
<Style Selector="^.clearButton, ^.ClearButton">
190191
<Style Selector="^[IsReadOnly=False]:focus /template/ Button#PART_ClearButton">
191192
<Setter Property="IsVisible" Value="True" />
@@ -200,12 +201,17 @@
200201
</Style>
201202

202203
<!-- IsEditingValid -->
203-
<Style Selector="^:invalid /template/ Label#PART_Id_IsEditing">
204-
<Setter Property="Foreground" Value="Red" />
205-
</Style>
206-
<Style Selector="^:invalid /template/ Label#PART_Id_IsEditing">
207-
<Setter Property="Foreground" Value="Red" />
204+
<!--
205+
<Style Selector="^:editing">
206+
<Style Selector="^ /template/ TextBox#PART_TextBox">
207+
<Setter Property="Foreground" Value="Green" />
208+
</Style>
209+
<Style Selector="^:invalid /template/ TextBox#PART_TextBox">
210+
<Setter Property="Foreground" Value="Red" />
211+
</Style>
208212
</Style>
213+
-->
214+
209215
<!--
210216
<Style Selector="^[IsEditingValid=true] /template/ Label#PART_Id_IsEditing">
211217
<Setter Property="Foreground" Value="Green" />

0 commit comments

Comments
 (0)