开发者

iterating through open windows in wpf

开发者 https://www.devze.com 2023-01-08 21:54 出处:网络
i\'m developing an application (wpf) that have 3 windows. in the main window user can open other window. when user wants to open window1 i\'m create an instance of window1 and showing up that

i'm developing an application (wpf) that have 3 windows. in the main window user can open other window. when user wants to open window1 i'm create an instance of window1 and showing up that

var win1 = new Window1();
win1.Owner = this;
win1.Show();

now when user wants to close app, i want to iterate through each open window and check if that window isn't busy (or if is busy wait to complete operation) close that window and t开发者_运维知识库hen close application. my question is how to iterating through open windows? maybe using this:

foreach (var window in Application.Current.Windows)
{
    window.
}

but how i can detect window is Window1 or Window2?


You can do

if(window is Window1)
{
   //window is of type 'Window1'!
}

Inside the 'foreach' loop.

0

精彩评论

暂无评论...
验证码 换一张
取 消