如何在PRISM中处理范围内的区域经理

时间:2018-06-18 23:33:09

标签: wpf prism

我正在创建一个范围区域管理器来处理对话框窗口,但是如果你必须在完成范围区域管理后清理它们,我就找不到任何信息。

我找不到任何关闭或处置方法,所以它们只是在垃圾收集器超出范围时处理,或者您是想先从中删除视图?

   public void ShowDialog(string region, string module, NavigationParameters navigationParameters, WindowPosition windowPosition, bool modal = true)
    {
        var dialog = _container.Resolve<DialogShellView>();

        //use a scoped region just in case you can have multiple instances
        var scopedRegion = _regionManager.CreateRegionManager();
        //set the region manager of the dialog to the scoped region
        RegionManager.SetRegionManager(dialog, scopedRegion);
        //navigate to show the desired view in the dialog
        scopedRegion.RequestNavigate(region, module, navigationParameters);
        //Set dialog position
        dialog.Top = windowPosition.Top;
        dialog.Left = windowPosition.Left;

        if (modal)
        {
            //show the dialog
            dialog.ShowDialog();
            scopedRegion.Regions.Remove(region);
        }
        else
        {
            dialog.Closed += (sender, e) => OnFinishEvent(sender, e, region, scopedRegion, dialog);
            dialog.Show();
        }
    }

0 个答案:

没有答案