Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

How to convert decimal to currency string while setBinding()?

$
0
0

"Price" has type decimal, e.g. Price is 1.02. But what I want for the priceBtn's Text to display is $1.02, so I tried the code below:
priceBtn.SetBinding(Button.TextProperty, new Binding("Price", stringFormat: "{0,:C2}"));
There is syntax error, but when I try the code below, the button is displaying 1.02:
priceBtn.SetBinding(Button.TextProperty, new Binding("prod.Price", stringFormat: "{0}"));

It looks like xamarin format item only supports {index} but not { index[,alignment][ :formatString] }.
Anyone know how to display currency from decimal? Thank you


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>