Is using value converters to generate GUI-friendly strings a misuse of value converters?

Posted by tempy on Stack Overflow See other posts from Stack Overflow or by tempy
Published on 2010-04-06T22:01:25Z Indexed on 2010/04/06 22:03 UTC
Read the original article Hit count: 376

Filed under:
|
|

Currently, I use value converters to generate user-friendly strings for the GUI. As an example, I have a window that displays the number of available entities in the status bar. The Viewmodel simply has an int dependency property that the calling code can set, and then on the binding for the textbox that displays the number of entities, I specify the int dependency property and a value converter that changes "x" into "x entities available".

My code is starting to become littered with these converters, and I have a large number of annoying resource declarations in my XAML, and yet I like them because all the GUI-specific string formatting is being isolated in the converters and the calling code doesn't have to worry about it. But still, I wonder if this is not the purpose that value converters were made for.

© Stack Overflow or respective owner

Related posts about wpf

Related posts about xaml