Merge branch 'release/AddNumInput'
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
@using System.Globalization
|
||||
|
||||
<input @bind="DisplValue" type="number" class="@CssClass" />
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
public string CssClass { get; set; } = "";
|
||||
|
||||
[Parameter]
|
||||
public string DisplFormat { get; set; } = "0.000";
|
||||
|
||||
[Parameter]
|
||||
public decimal Value
|
||||
{
|
||||
get => decimalVal;
|
||||
set => decimalVal = value;
|
||||
}
|
||||
|
||||
// [Parameter]
|
||||
// public double ValueDouble
|
||||
// {
|
||||
// get => (double)decimalVal;
|
||||
// set => decimalVal = (decimal)value;
|
||||
// }
|
||||
|
||||
protected string DisplValue
|
||||
{
|
||||
get => decimalVal.ToString(DisplFormat, culture);
|
||||
set
|
||||
{
|
||||
if (Decimal.TryParse(value, style, culture, out var number))
|
||||
{
|
||||
decimalVal = Math.Round(number, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private decimal decimalVal { get; set; } = 0;
|
||||
private NumberStyles style = NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign;
|
||||
private CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US");
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user