Jeremy Likness on Clean Design-Time Friendly ViewModels
There are numerous ways of handling design-time data in view-models. While some people use complex dependency injection frameworks or inversion of control containers, the simplest method is to just check the DesignerProperties.IsInDesignTool flag. Unfortunately this has the side effect of embedding the design-time data into one’s application. Jeremy Likness offers a couple ways of working around this.
His first proposal is the use of partial methods and compiler constants. If the partial method that loads the data, named _WireDesignerData in his example, is excluded from the release build then any calls to it will also be removed.
Another option is the Conditional attribute. This has the same net effect, but doesn’t require the use of partial classes and #if blocks to remove the design-time code.
InfoQ Asks: What is your favorite strategy for handling design-time data?
As a side note, the issue of IoC is (or should be) completely orthogonal to design-time data issues. IoC is critical for the decomposition of a complex UI and for the long-term maintenance and extensibililty plan. You should not have to trade off building a good app, just so you can get a tool to show decent values in a text box at design-time.
Sorry if this sounded like a rant, but this question highlights a problem that which has nothing to do with building good software. It's a problem that was created by Microsoft and thrust on the developer; and it's a problem they refuse to engage experienced members of the community on. None of this should be an issue.