"The Last Visibility Converter" (you'll ever need)
Compiled Experience - The last Visibility Converter
The Boolean to Visibility Converter is as close you’re going to get to bread and button in the xaml frameworks. You need it in almost every app and almost every framework has one, even the Windows 8 project templates come with one.
The trouble is that a lot of these implementations are naïve and simplistic, and soon enough you’ll be writing “Inverse Boolean to Visibility Converter”, “Int32 to Visibility Converter” etc. Ultimately these all exhibit very similar behavior, convert the default value (false, 0, null etc.) to Collapsed and anything else to Visible or do the same but inversed. Having over a dozen converters for all the implementations becomes a pain to manage and awkward.
So let’s build the last Visibility Converter you’ll need, we’ve already defined what the behavior should be, “Convert the default value to Collapsed and everything else to Visible”. ...
..."
Until we get one as part of the Framework (which I kind of doubt will happen) I'm going to let him do the work and let Nigel do the work for my last Visibility Converter... (Good developers code, Great developers... ;)
No comments:
Post a Comment