启动无模式窗口的建议方法是什么,但强制使用Caliburn Micro在应用程序中只有一个已启动窗口的实例?
答案 0 :(得分:2)
我不确定这是否是批准的方法;但是,这是我过去所做的,以确保一次只打开一个窗口的单个实例。请注意,没有任何特定的方法,使用Caliburn来创建模态类型窗口;你需要自己设置窗口。
// 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 );
}