Skip to content

Commit 919c6f8

Browse files
committed
fix(numberbox): fix compile errors and warnings
1 parent d7802a6 commit 919c6f8

File tree

3 files changed

+9
-30
lines changed

3 files changed

+9
-30
lines changed

src/Wpf.Ui.Demo.Simple/MainWindow.xaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
<Grid.RowDefinitions>
3434
<RowDefinition Height="Auto" />
3535
<RowDefinition Height="*" />
36-
<RowDefinition Height="100" />
3736
</Grid.RowDefinitions>
3837

3938
<ui:NavigationView x:Name="RootNavigation" Grid.Row="1">
@@ -94,10 +93,5 @@
9493
<ContextMenu ItemsSource="{Binding ViewModel.TrayMenuItems, Mode=OneWay}" />
9594
</tray:NotifyIcon.Menu>
9695
</tray:NotifyIcon>
97-
98-
<StackPanel Grid.Row="2">
99-
<ui:NumberBox Value="{Binding Value}"/>
100-
<ui:TextBlock Text="{Binding Value}" />
101-
</StackPanel>
10296
</Grid>
10397
</ui:FluentWindow>

src/Wpf.Ui.Demo.Simple/MainWindow.xaml.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,6 @@ namespace Wpf.Ui.Demo.Simple;
1414
/// </summary>
1515
public partial class MainWindow : INotifyPropertyChanged
1616
{
17-
private double _value;
18-
19-
public double Value
20-
{
21-
get => _value;
22-
23-
set
24-
{
25-
_value = value;
26-
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Value)));
27-
}
28-
}
29-
3017
public MainWindow()
3118
{
3219
DataContext = this;

src/Wpf.Ui/Controls/NumberBox/NumberBox.cs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
33
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
44
// All Rights Reserved.
5-
65
// This Source Code is partially based on the source code provided by the .NET Foundation.
76

87
using System.Windows.Controls;
@@ -20,8 +19,8 @@ namespace Wpf.Ui.Controls;
2019
/// <summary>
2120
/// Represents a control that can be used to display and edit numbers.
2221
/// </summary>
23-
//[ToolboxItem(true)]
24-
//[ToolboxBitmap(typeof(NumberBox), "NumberBox.bmp")]
22+
// [ToolboxItem(true)]
23+
// [ToolboxBitmap(typeof(NumberBox), "NumberBox.bmp")]
2524
public class NumberBox : TextBox
2625
{
2726
private bool _valueUpdating;
@@ -80,7 +79,7 @@ public class NumberBox : TextBox
8079
nameof(Maximum),
8180
typeof(double),
8281
typeof(NumberBox),
83-
new PropertyMetadata(Double.MaxValue)
82+
new PropertyMetadata(double.MaxValue)
8483
);
8584

8685
/// <summary>
@@ -90,7 +89,7 @@ public class NumberBox : TextBox
9089
nameof(Minimum),
9190
typeof(double),
9291
typeof(NumberBox),
93-
new PropertyMetadata(Double.MinValue)
92+
new PropertyMetadata(double.MinValue)
9493
);
9594

9695
/// <summary>
@@ -231,7 +230,7 @@ public double Minimum
231230
}
232231

233232
/// <summary>
234-
/// Gets or sets whether the control will accept and evaluate a basic formulaic expression entered as input.
233+
/// Gets or sets a value indicating whether the control will accept and evaluate a basic formulaic expression entered as input.
235234
/// </summary>
236235
public bool AcceptsExpression
237236
{
@@ -312,7 +311,6 @@ protected override void OnKeyUp(KeyEventArgs e)
312311
UpdateValueFromText();
313312
ValidateValue(Value);
314313
MoveCaretToTextEnd();
315-
TriggerValueUpdate();
316314
}
317315

318316
break;
@@ -368,7 +366,7 @@ ControlTemplate newTemplate
368366
base.OnTemplateChanged(oldTemplate, newTemplate);
369367

370368
// If Text has been set, but Value hasn't, update Value based on Text.
371-
if (String.IsNullOrEmpty(Text) && Value != null)
369+
if (string.IsNullOrEmpty(Text) && Value != null)
372370
{
373371
SetCurrentValue(ValueProperty, null);
374372
}
@@ -391,7 +389,7 @@ protected override void OnLostFocus(RoutedEventArgs e)
391389
/// </summary>
392390
protected virtual void OnValueChanged(DependencyObject d, double? oldValue)
393391
{
394-
var newValue = Value;
392+
double? newValue = Value;
395393

396394
if (Equals(newValue, oldValue))
397395
{
@@ -425,7 +423,7 @@ private void ValidateValue(double? newValue)
425423
// Correct the text from value
426424
if (Value is null && Text.Length > 0)
427425
{
428-
SetCurrentValue(TextProperty, String.Empty);
426+
SetCurrentValue(TextProperty, string.Empty);
429427
}
430428
else if (GetParser().ParseDouble(Text.Trim()) != Value)
431429
{
@@ -444,7 +442,7 @@ private void StepValue(double? change)
444442
);
445443
#endif
446444

447-
var newValue = Value ?? 0;
445+
double newValue = Value ?? 0;
448446

449447
if (change is not null)
450448
{

0 commit comments

Comments
 (0)