I have the following code in XAML:
<TextBlock Text="{Binding XValue}" />
The XValue contains a lot of decimals(1952.230822830529)
I want it to contain only 2 decimals like 1952.23 and i want to do this in the XAML code.
I have searched the internet but not found a solution to my problem - so is it even to do this in XAML using string format?
This is a duplicate of this post (also the top result on google): How to format number of decimal places in wpf using style/template?
Try one of these:
<TextBox Text="{Binding XValue, StringFormat=N2}" />
<TextBox Text="{Binding XValue, StringFormat=#,#.00}" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With