views:

62

answers:

2

i read that i can use data converters in binding like ...

<TextBlock Text="{Binding Converter={StaticResource PositionConverter}}" />

from here

but i wonder if there are any "in-built" converters. because creating converters to just output say 2 decimal places etc seem troublesome. i just thought that there must be sometime inbuilt that i can use?

+3  A: 

Here is the list of all converters provided by the framework

CommanderZ
+1 Nice. Are they already instantiated at any point with a known (and stable) resource-key so that they can be used without declaring them newly in xaml?
HCL
I don't think so, but I guess you can instantiate them in app.xaml once and have them available in whole app.
CommanderZ
@commanderz: Yes, this is also more reliable in case of the keys will be changed in further versions of the fcl. Thanks.
HCL
+4  A: 

For a list of built-in converters, see commanderz's answer

creating converters to just output say 2 decimal places etc seem troublesome

Indeed, and you don't need to ;)

Instead, you can use the StringFormat property to specify a format specifier:

<TextBlock Text="{Binding SomeValue, StringFormat=F2}" />

See this page for details on formatting and lists of valid format specifiers.

Thomas Levesque