2011-07-25 8 views
0

私はプリズムが新しく、ホストアプリケーションからWPFクラスライブラリ(PrismとMEF)にオブジェクトリファレンスを渡す方法を理解しようとしています。Prismを使用してオブジェクトをWPFクラスライブラリに渡す方法

ありがとうございます!私のホストアプリで

、ボタンのクリックは、WPFのクラスライブラリを呼び出す:

public override void OnClick() 
    { 
     //need to pass some object reference into 
     TestButtonBootstrapper bootstrapper = new TestButtonBootstrapper(); 
     bootstrapper.Run(); 


    } 

私のブートストラップ:プリズム内で

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; 

     //Application.Current.MainWindow = (Shell)this.Shell; 
     //Application.Current.MainWindow.Show(); 
    } 
+1

この質問をより明確にするには、ホスティングアプリケーションからPrismアプリケーションに渡そうとしているオブジェクトの種類に関する情報をお知らせください。 –

答えて

0

、ブートストラップは、あなたのメインの実行可能ファイルを起動して提供することを意図していますホストアプリケーションと構成されたモジュール間の配線。

App.xaml.csでは、ブートストラップをインスタンス化して実行するように、起動コードを変更します。

public partial class App : Application 
{ 
    protected override void OnStartup(StartupEventArgs e) 
    { 
     new MyBootstrapper().Run(); 
    } 
} 

アプリケーションの起動時に次の2つのメインウィンドウを取得しないように、App.xamlからStartupUriを削除してください。

+0

これはスタンドアプリケーションではなく、別のウィンドウアプリでホストされているdllであるため、私はapp.xamlを持っていません。したがって、ホスト上のボタンをクリックするとstarupのように動作します。 – julie6

関連する問題