如何在WPF C#中最小化子窗口时访问主窗口 [英] How to access Main window when child window minimized in WPF C#

查看:397
本文介绍了如何在WPF C#中最小化子窗口时访问主窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我使用的主窗口有员工详细信息,还有一个子窗口。在父窗口中,我有一个员工成就按钮。当我单击按钮时,在子窗口中打开成就说明。它工作正常。但是当我最小化子窗口时,我需要访问我的父窗口。儿童窗口仅供参考。



任何人都可以向我推荐解决方案。



问候,

Arunkumar M

Hi Everyone,

I have used main window which is having employee details and also having one child window. In parent window i have one button for employee achievements. when i click the button the achievements descriptions opened in child window. It works fine. But when i minimized the child window i need to access my parent window. Child window is used only for reference.

Can anyone please suggest me the solution.

Regards,
Arunkumar M

推荐答案

您可以随身携带App.Current.Windows,在此帮助下,您可以找到您的mainWindow (根据名称或基于窗口名称)并激活它或通过下面提到的代码在您的子窗口中显示





You can have App.Current.Windows with you,with the help of this, you can find out your mainWindow(based on name or based on window name)and get it activated or get it shown by below mentioned code in your child window


foreach (Window win in App.Current.Windows)
            {
                //In case of "Mainwindow" here you can set your respective Mainwindow object in wpf
                if (win.GetType() == typeof(MainWindow))
                {
                    win.Activate();
                    break;
                }
            }


这篇关于如何在WPF C#中最小化子窗口时访问主窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆