简体   繁体   English

xaf window.close 不工作。 如何关闭一个窗口?

[英]xaf window.close not working. How to close a window?

I tried the following code to close an XAF window.我尝试了以下代码来关闭 XAF 窗口。

  public static bool CloseViewIfOpen(XafApplication application, string listViewId)
    {
        if (!(application.ShowViewStrategy is WinShowViewStrategyBase strategy)) return false;
        foreach (var win in strategy.Windows.ToArray())
        {
            if (win.View == null) continue;
            if (!win.View.Id.Equals(listViewId)) continue;
            win.Close();
            return true;

        }
        return false;
    }

However the code does not work.但是代码不起作用。 Looking inside the DevExpress.ExpressApp.WinWindow close method, I see that it does nothing and returns false.查看 DevExpress.ExpressApp.WinWindow 关闭方法的内部,我看到它什么也不做,并且返回 false。

关闭代码

Is there any other way to close the winwindow in code?有没有其他方法可以在代码中关闭winwindow?

I need to close the XAF window so that I can re-construct it's nested listview collection source.我需要关闭 XAF 窗口,以便我可以重新构建它的嵌套列表视图集合源。

The user can close the window via the UI.用户可以通过 UI 关闭窗口。

I am using XAF 21.2.8我正在使用 XAF 21.2.8

The docs are here .文档在这里

I tried calling win.Dispose but the win.controllers collection remains preventing the dispose.我尝试调用 win.Dispose 但 win.controllers 集合仍然阻止处置。

    public static bool CloseViewIfOpen(XafApplication application, string listViewId)
    {
        if (!(application.ShowViewStrategy is WinShowViewStrategyBase strategy)) return false;
        foreach (var win in strategy.Windows.ToArray())
        {
            if (win.View == null) continue;
            if (!win.View.Id.Equals(listViewId)) continue;
            win.View.Close();
            return true;
        }
        return false;
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM