Terje Isaksen Developer blog

2009-11-24 (Tuesday)

Numeric to string

Filed under: Developing — Terje Isaksen @ 17:25
Tags: ,

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:




Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog at WordPress.com.

%d bloggers like this: