Hi,
I would like to allow either comma and dot as decimal separator in GridViewDataColumn.
Where Quantity is :
The ViewModel set those parameters in constructor :
Result :
When the cell isn't in EditMode, if quantity is 4,268, the cell displays 4.27 : it's why I want.
But when the cell is in EditMode: if user write 4.58 for example, the value isn't recognize as a valid double and is converted back. When writting 4,58, the value is successfully recognized.
Thanks
I would like to allow either comma and dot as decimal separator in GridViewDataColumn.
<
telerik:GridViewDataColumn
Header
=
"Qté"
DataMemberBinding
=
"{Binding Quantity, Mode=TwoWay}"
/>
Where Quantity is :
private
double
_quantity;
public
double
Quantity
{
get
{
return
OrderUnit == PackagingUnit.Kilogram ? Math.Round(_quantity, 3) : Math.Round(_quantity, 0); }
set
{
if
(_quantity == value)
return
;
_quantity = value;
RaisePropertyChanged(ReflectionUtility.GetPropertyName(() => Quantity));
Refresh();
}
}
The ViewModel set those parameters in constructor :
var culture =
new
CultureInfo(
"fr-FR"
,
false
);
culture.NumberFormat.CurrencyDecimalSeparator =
"."
;
culture.NumberFormat.NumberDecimalSeparator =
"."
;
culture.NumberFormat.PercentDecimalSeparator =
"."
;
culture.Parent.NumberFormat.CurrencyDecimalSeparator =
"."
;
culture.Parent.NumberFormat.NumberDecimalSeparator =
"."
;
culture.Parent.NumberFormat.PercentDecimalSeparator =
"."
;
LocalizationManager.DefaultCulture = culture;
Dispatcher.CurrentDispatcher.Thread.CurrentCulture = culture;
Dispatcher.CurrentDispatcher.Thread.CurrentUICulture = culture;
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
Result :
When the cell isn't in EditMode, if quantity is 4,268, the cell displays 4.27 : it's why I want.
But when the cell is in EditMode: if user write 4.58 for example, the value isn't recognize as a valid double and is converted back. When writting 4,58, the value is successfully recognized.
Thanks