1

I'm currently using MVVM in a WPF project, all works very well. I have one Master view and many Detail views that I manage using a currentView property in my MasterViewModel. By using a datatemplate, I bind a view to a viewmodel. In fact, my master view has a contentcontrol whose content property is binded to my CurrentView property. When I set this currentview property to a viewmodel or another, it calls the corresponding template.

My problem is that using this, my detail views doesn't have explicit datacontext because it is placed by my datatemplate. So in blend, when I open my view to edit its design, I have no datas to bind to my view. If I set a datacontext to my detailview, in blend I can see all datas I can bind but in runtime, the datacontext set by datatemplate is overrided by the datacontext set in my detailview, so I have no datas during runtime.

Does anyone knows how I can create a good MVVM project, with views managed by datatemplates and with datacontext that we can see with Blend ?

Thanks,

4

2 回答 2

2

我有一篇关于这个问题的博客文章:http ://www.robfe.com/2009/08/design-time-data-in-expression-blend-3/

我的帖子都是关于在混合中显示数据,不必在运行时显示甚至创建该数据。

于 2009-10-05T13:45:24.570 回答
1

我在这篇文章中解决了一个类似的问题: 如何使用 Expression Blend 编辑在 Visual Studio 中创建的 DataTemplate?

于 2009-05-05T13:32:25.773 回答