How to set a value to display for bound properties in WPF design mode? – Stack Overflow

via How to set a value to display for bound properties in WPF design mode? – Stack Overflow

An easy way to get Design-time-data in Visual Studio 2010 is to use a design-datacontext.

Short example with a Window and a ViewModel, For DataContext, the d:DataContext will be used in Design-mode and the StaticResource will be used in runtime. You can also use a separate ViewModel for design but in this example I will use the same ViewModel for both.

<Window ...
        d:DataContext="{d:DesignInstance local:YourDesignModeViewModel, IsDesignTimeCreatable=True}">
        <local:MyViewModel x:Key="MyViewModel" />
        <StaticResource ResourceKey="MyViewModel"/>
        <TextBox Text="{Binding MyText}"

Hope this is helpful!



4 responses to this post.

  1. Posted by Dạ Vũ on December 4, 2010 at 5:44 PM

    i begin learning ADO.NET and feel Entity Framework really userful. Can you tutorial something about it? Pleaze! ! ! I understand the way it action with data, i don’t know how to coding to run a simple application. Plzzz!


    • I’d love to ^_^ Would you start a new post showing what you have done so far? If you don’t have a blog, please join with me writting on my blog.


      • Posted by Dạ Vũ on December 5, 2010 at 6:13 PM

        i have many blogs but i just like design and coding for beautiful effects. If writing about technology or progaming, i worry they say : ” Teach one’s grandmother to suck eggs ” ^^. Also, my ability writing is so bad…

      • @Vu: Can I have your blogs’ url(s)?
        About tech/programming blog, it is an action of sharing so that 1) you can verify yourself, 2) your knowledge can help the follower. Don’t worry about “mother suck eggs” since there are hundreds of newbie looking for how to “suck eggs” indeed

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: