lundi 29 juin 2015

how to get count of number of opened windows in WPF

I have a requirement that, if one window is opened then user can not allow to open other window, for that I have tried following code.

if(System.Windows.Application.Current.Windows.Count == 0)

{

-- My code

}

I am checking for currently opened window count, if it is greater then 1 then user can not open other window and that I will mention inside if statement,

but when I run this code it gives me the error "Object reference not set to an instance of an object."

Any Solution

Aucun commentaire:

Enregistrer un commentaire