1

モードレスウィンドウを起動するための推奨される方法は何ですか?ただし、Caliburn Microを使用して、アプリケーションに起動されたウィンドウのインスタンスが1つだけであることを強制しますか?

4

1 に答える 1

3

これが承認された方法かどうかはわかりません。ただし、これは、ウィンドウの1つのインスタンスのみが一度に開かれるようにするために過去に行ったことです。モーダルタイプウィンドウを作成するためのCaliburnには、特定の方法afaikがないことに注意してください。自分でウィンドウを設定する必要があります。

// Create a reference to the model being used to instantiate the window
// and let the IoC import the model. If you set the PartCreationPolicy
// as Shared for the Export of SomeOtherModel, then no matter where you are
// in the application, you'll always be acting against the same instance.
[Import]
private SomeOtherModel _otherModel;


public void ShowSomeOtherWindow()
{
    // use the caliburn IsActive property to see if the window is active
    if( _otherModel.IsActive )
    {
        // if the window is active; nothing to do.
        return;
    }

    // create some settings for the new window:
    var settings = new Dictionary<string, object>
                   {
                           { "WindowStyle", WindowStyle.None },
                           { "ShowInTaskbar", false },
                   };

    // show the new window with the caliburn IWindowManager:
    _windowManager.ShowWindow( _otherModel, null, settings );
}
于 2012-10-12T01:01:19.340 に答える