How to round double in XAML, WPF?
I have the following code in XAML:
<TextBlock Text="{Binding XValue}" />
XValue contains many decimal places (1952.230822830529)
I want it to contain only 2 decimal places, such as 1952.23, and I want to do this in XAML code.
I searched the Internet, but did not find a solution to my problem - is it possible to do this in XAML using the string format?
This is a duplicate of this post (also the main result in google): How to format the number of decimal places in wpf using style / pattern?
Try one of the following:
<TextBox Text="{Binding XValue, StringFormat=N2}" />
<TextBox Text="{Binding XValue, StringFormat=#,#.00}" />