Binding a textbox to a numeric source and formatting it is done by

```
<TextBox Text="{Binding Path=Fieldname, StringFormat=formatstring}"/>
```

where “formatstring” can for example be any of following:

Fn – fixed point number – where n= number of decimals

Pn – percentage (value is multiplied with 100 and displayed with a %-symbol) – where n = number of decimals

Dn – integer – where n= number of digits

Nn – number with decimals and group separators, where n=number of decimals

Xn – hexadecimal integer – where n= number of digits

It can also be a string of custom numeric format characters inside a pair of single quotes which for example can be:

0 – zero placeholder, gives a digit if present – zero otherwise

# – digit placeholder, gives a digit if present, nothing otherwise

. – decimal point – determines where the decimal seperator should be

, – group separator – gives the localized group separator. Can also be used at the end to divide the number with 1000 for each comma

% – percentage placeholder – if at the end – multiplies number with 100 and gives percentage symbol at end

See more at:

http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx

http://msdn.microsoft.com/en-us/library/0c899ak8.aspx

http://blogs.msdn.com/llobo/archive/2008/05/19/wpf-3-5-sp1-feature-stringformat.aspx

```
```