Class WholeNumberConverter
- Namespace
- McServerLauncher.ViewModels
- Assembly
- McServerLauncher.dll
Binds an int setting to a Avalonia.Controls.NumericUpDown, whose value is a
decimal? that is null while the box is empty.
public class WholeNumberConverter : IValueConverter
- Inheritance
-
WholeNumberConverter
- Implements
-
IValueConverter
- Inherited Members
Remarks
An empty box writes nothing, rather than failing to write a null into an int and showing the
exception under the box. WholeNumberBoxes puts the number back once the box is
left empty.
Fields
Instance
public static readonly WholeNumberConverter Instance
Field Value
Methods
Convert(object?, Type, object?, CultureInfo)
Converts a value.
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
Parameters
valueobjectThe value to convert.
targetTypeTypeThe type of the target.
parameterobjectA user-defined parameter.
cultureCultureInfoThe culture to use.
Returns
- object
The converted value.
Remarks
This method should not throw exceptions. If the value is not convertible, return a Avalonia.Data.BindingNotification in an error state. Any exceptions thrown will be treated as an application exception.
ConvertBack(object?, Type, object?, CultureInfo)
Converts a value.
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
Parameters
valueobjectThe value to convert.
targetTypeTypeThe type of the target.
parameterobjectA user-defined parameter.
cultureCultureInfoThe culture to use.
Returns
- object
The converted value.
Remarks
This method should not throw exceptions. If the value is not convertible, return a Avalonia.Data.BindingNotification in an error state. Any exceptions thrown will be treated as an application exception.
ToWhole(decimal)
A box's value as the whole number it stands for, rounded the way the box shows it.
public static int ToWhole(decimal value)
Parameters
valuedecimal
Returns
Remarks
The one place a box's decimal becomes an int. Some code used to cast instead,
which truncates: a box showing 3 (its format rounds 2.5) wrote 2.