3

I'm trying to improve on my design time experience in Blend.

I know I can do something like:

d:DataContext="{d:DesignInstance local:vm_d, IsDesignTimeCreatable=True}"

and blend/vs will show my bindings to vm_d at design time, however this seems somewhat limited (i.e. when using DI, generics, not to mention it seems odd to me that I have to edit XAML by hand to "improve my design time experience").

What I'd rather do is something like this in the code behind:

public SimpleLoad()
    {
        InitializeComponent();
        DataContext = new vm_d();
    }

I assume one problem is I need to set IsDesignTimeCreatable? In any case does anyone have an idea how I could implement this?

foo
  • 1,495
  • 2
  • 11
  • 15

1 Answers1

0

Add something allong these lines in the constructor (or PageLoaded handler):

        if (DesignerProperties.IsInDesignTool)
        {
            SimpleLoad();
        }
Tim Dams
  • 747
  • 1
  • 6
  • 15
  • I think maybe I wasn't clear in my original post. In your answer you suggest calling SimpleLoad in the constructor, but SimpleLoad is my constructor. The idea is I want to have some logic in the constructor that determines (depending on whether or not we are in design mode) which view model to create (the real one or a dummy just to use at design time). – foo Feb 21 '12 at 16:36