Number formatter

Hi guys, i made little expression class for number formatting like this 200000 => 200.000

MoneyStringFunction.uno


using Uno; 
using Uno.UX; 
using Fuse.Reactive;
  
[UXFunction("money")]
public sealed class Money: BinaryOperator
{
	[UXConstructor]
	public Money([UXParameter("Left")] Fuse.Reactive.Expression left, [UXParameter("Right")] Fuse.Reactive.Expression right): 
		base(left, right, "money") {}
		
	protected override bool TryCompute(object left, object right, out object result)
	{
		result =string.Format("{0:N"+right+"}",left); 

		return true;
	}
}

usage :

<JavaScript>
module.exports={
TotalPrice:200000
};
</JavaScript>

<Text Value="{=money({TotalPrice},2)}" />   ~> this shown in text 200.000,00 | 2 is decimal place

1 Like