我正在尝试显示模态对话框,我需要参考当前的 Shell 窗口:
public class OpenPopupWindowAction : TriggerAction<FrameworkElement>
{
protected override void Invoke(object parameter)
{
var popup = new ChildWindow(); //(ChildWindow)ServiceLocator.Current.GetInstance<IPopupDialogWindow>();
popup.Owner = PlacementTarget ?? (Window)ServiceLocator.Current.GetInstance<IShell>();
我越来越:
Cannot set Owner property to a Window that has not been shown previously.
这是来自 Bootstrapper 的代码
public class Bootstrapper : UnityBootstrapper
{
protected override System.Windows.DependencyObject CreateShell()
{
Container.RegisterInstance<IShell>(new Shell());
return Container.Resolve<Shell>();
界面:
public interface IShell
{
void InitializeComponent();
}
public partial class Shell : Window, PrismDashboard.IShell