开发者

How to create WPF/Silverlight module utilizing prism but also that can be embedded in non-prism applicationss

开发者 https://www.devze.com 2023-01-30 15:44 出处:网络
I want to have create a WPF or Silverlight modulewhich cannot only be utilised by Shell\'s bootstrapper, b开发者_如何转开发ut also can be embedded in non-PRISM applications.

I want to have create a WPF or Silverlight module which cannot only be utilised by Shell's bootstrapper, b开发者_如何转开发ut also can be embedded in non-PRISM applications.

In short is there a way PRISM module can be intialised from module itself rather than initialsing from Shell?

Ulimate goal is to have WPF/Silverlight PRISM module, which can be initialsed by non-PRISM applications.


There is no barrier to this.

The IModule interface has a single, parameterless void method: Initialize().

A non-prism application can initialize the module by calling that method. That's it.

If the other application has a different plugin system, with a different interface, your module can implement that interface as well, and the body of whatever initialization method that interface uses can simply call Initialize(), or vice versa.

For example:

public interface IMyPluginModule
{
    void StartModule();
}

public class MyModule : IModule, IMyPluginModule
{
    public void Initialize()
    {
        // actual initialization code here
    }

    public void StartModule()
    {
        Initialize();
    }
}


It's a little more complicated than it appears at first glance, but it is doable. I don't know if you are using Prism 4 yet, but if so, Microsoft actually provides guidance for this scenario:

http://msdn.microsoft.com/en-us/library/ff921109(v=PandP.40).aspx

There is a bit of project manipulation you need to do to get two projects running side-by-side. There is a sample included with Prism v4 called "MultiTargeting" if you need to see a working sample.

Your question regarding to allowing a module to be initialized by itself, rather than having the orchestrating Shell / Bootstrapper is the wrong approach, however. Essentially what you would have would be two shells... one WPF and one Silverlight. Take a look at the samples and see what you think.

Hope this helps.

0

精彩评论

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