开发者

How to export Application.Current with MEF in SL3?

开发者 https://www.devze.com 2023-02-14 17:25 出处:网络
I seem to be stuck. Is there a way to export Appli开发者_如何学Gocation.Current of a Silverlight project using MEF, so that when I load .XAP (my Silverlight component project) file I had access to th

I seem to be stuck. Is there a way to export Appli开发者_如何学Gocation.Current of a Silverlight project using MEF, so that when I load .XAP (my Silverlight component project) file I had access to the App of that .xap?


There isn't really a need for this. Since Application.Current is already a singleton, it's going to exist once your .xap is loaded in any case. You shouldn't need to export it via MEF - your component will already be able to access it directly.


Try this:

Container.ComposeExportedValue(Application.Current);

where Container is MEF's CompositionContainer.

0

精彩评论

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

关注公众号