in

WPF Design and Development

IdentityMine Team Blogs

Sajiv Thomas

WPF DataBinding, 3D, Graphics, Controls, Silverlight

Formatting data in WPF DataBinding.

An easy way for formatting data according to our needs in WPF data binding is to use a Converter alongwith a ConverterParameter.

As seen below, all we need to do is write a converter which takes Format String as a parameter. Inside the converter we can format the data based on the Format String passed in as the converter parameter.

 

<TextBlock Text="{Binding Path=Price,Converter={StaticResource formatter},ConverterParameter='\{0:C\}'}"/>

 

Note:Since the Format String has curly brackets we need to escape these using backslash.

Published Aug 03 2007, 01:27 AM by Sajiv
Filed under:

Comments

No Comments
© 2007 IdentityMine, Inc.
Powered by Community Server (Commercial Edition), by Telligent Systems