09 Oct 2011
ValueConverter seems like just the ticket for handling data types whose domains are finite sets of named values (think enum). But how do you get the domain definition into scope? Resource dictionaries are wonderful until you find they’re out of scope. And they’re always out of scope for the code of a ValueConverter. You can’t pass them in as ConverterParameter because it isn’t a DependencyProperty.
What you can do is use a MultiBinding and a MultiConverter, and pass the resource as one of the binding values. This rather good trick also works for DynamicResource, so you can declaratively marshal into scope a completely arbitrary value that doesn’t even exist till run-time.
Unless indicated otherwise, all blog entries for On Second Thought are original works by Peter Wone