开发者

Ideal place to compose parts when using MEF + MVVM light toolkit?

Now that I'm working on my newer application that uses MEF with the MVVM light toolkit, I've run into a case where I can't load specific plugins because they rely on a part that isn't getting exported. That part isn't getting exported because it's a View, and the View isn't resolved with MEF (yet).

It seems that every time I play with MEF, I need to move the part composition step (i.e. create container, catalog, then compose parts) closer and closer to the main application. I believe that I am now at that point. However, the problem is that I'm not sure exactly where to put it.

I'd like to put it MainWindow, which I believe is created by the MVVM light tookit project template. I have used the Export attribute on MainViewModel and Model. I am importing the ViewModel in the ViewModelLocator, 开发者_StackOverflow社区and I import the Model in the ViewModel. To me, this seems like enough to ensure that everything gets composed properly. However, while the ViewModel is composed properly (it hits its constructor), the Model is not. I checked the output window during composition, and I don't get any MEF errors there.

So in summary, these are my issues: 1. Where is the "right" place to compose parts? In the WPF / MVVM case, would it always be at the start of the app? 2. In the absence of MEF errors in the output window, what are other techniques to figure out why things aren't getting resolved? Normally, I will step all the way through Compose to try to get some insight. Are there better debugging techniques than this? 3. Can you think of why my Model wouldn't get loaded? 4. Are there good MEF + MVVM light toolkit projects I can download to study?


Just use MEFedMVVM and you will not have any of these problems. As the name suggests it has been build from the ground up to solve the type of issues that you are mentioning. And it has a lot more precious features for building mvvm apps. Good luck.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜