inject object from host app to hosted WPF app using Prism

Jul 25, 2011 at 1:35 PM

Hi,

I'm new to Prism. I'm implementing a class library (using Prism MEF) for a Win app. I have created a Shell and bootstrapper and they work. Now I need to pass object from the host Win app into this class library. How to do this?

Thanks!

This is the call in host app:

public class ButtonMain : ESRI.ArcGISExplorer.Application.Button
    {
        public override void OnClick()
        {
            //need to pass "ESRI.ArcGISExplorer.Application.Application"
            TestButtonBootstrapper bootstrapper = new TestButtonBootstrapper();
            bootstrapper.Run();

            
        }
    }
This is my bootstrapper code:
public class TestButtonBootstrapper : MefBootstrapper
    {            
        protected override DependencyObject CreateShell()
        {
            return this.Container.GetExportedValue<Shell>();
        }

        protected override void InitializeShell()
        {
            base.InitializeShell();

            if (System.Windows.Application.Current == null)
            {
                new System.Windows.Application();
            }
            System.Windows.Application.Current.MainWindow = (Shell)this.Shell;
            System.Windows.Application.Current.MainWindow.Show();
            System.Windows.Application.Current.MainWindow.Height = 600;
            System.Windows.Application.Current.MainWindow.Width = 250;
        }