0

I want to have my user controls have design time data. If I add the data/datacontext using the constructor, I can see the data in the control from a different view that contains the control.

If I set the DataContext from xaml, I can see it when I'm designing the control, but I see nothing in a control that hosts the control.

So is there any example of how to get design time data to show up in a control if it is being edited, or it's parent is being edited? Or anything that lists the rules of then the constructor is run/not run from the designer? I'm trying to set a DesignViewModel with the data, and at runtime use the actual view model.

NotDan
  • 31,709
  • 36
  • 116
  • 156

1 Answers1

2

If I understand your question correctly then it's answered in this question

Community
  • 1
  • 1
Fredrik Hedblad
  • 83,499
  • 23
  • 264
  • 266
  • That's pretty cool, unfortunately it only works on the currently edited control. So if I have a BookView, when I'm designing BookView then I can see the data. But if I have another control that contains a BookView, and I am editing the other control, all of BookView is blank and doesn't have the design data.. – NotDan Dec 08 '10 at 22:11
  • It looks like this is by design, so you can use different sample data in the containing control. https://connect.microsoft.com/VisualStudio/feedback/details/555272/silverlight-forum-designcontext-and-d-designinstance-discarded-in-nested-usercontrols – NotDan Dec 08 '10 at 22:16