BindingBase.StringFormat Property (System.Windows.Data)

October 07, 2010 | WPF

By default the WPF binding engine uses 2 fractional digits when displaying double values. When those digits are zero though, they are omitted. You can override this by specifying the StringFormat Property on the binding.

Text="{Binding Path=Price, StringFormat={}{0:0.00}}"

StringFormat can be a predefined, composite, or custom string format. For more information about string formats, see Formatting Types here.