Coffeehouse Post

Single Post Permalink

View Thread: Do you find WPF to be unnatural / unlogical?
  • User profile image
    Maddus Mattus

    This is what we do;

          <MockViewModels:MyFirstViewModel />
    in the code behind;
    public MyFirstViewModel ViewModel
    set { DataContext = value; }

    So when the app is run in Blend, we get no import from MEF and we get a MockViewModel. Saves me the effort of creating a modellocator. In the MockViewModel we do not build data if it's in Design mode.

    You could work with a shared interface between the mock and the actual model, but that just creates more classes. This is the most clean IMO.

    I've used the modellocator pattern in XAML on other projects, but it always tends to add much code, either in XAML or in C#. For simple things I use the solution above.