Jiew Meng
Jiew Meng

Reputation: 88317

Any default converters for WPF?

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?

Upvotes: 6

Views: 5987

Answers (2)

Thomas Levesque
Thomas Levesque

Reputation: 292615

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.

Upvotes: 6

Related Questions