I'm writing a program using WPF(C#). I use method like this to open and close windows:
public static void openCloseWindow(Window toBeOpen, Window toBeClose)
{
    toBeOpen.Show();
    makeWindowCenter(toBeOpen);
    toBeClose.Close();
}
In part of program I use this method like this:
openCloseWindow(new BestCustomerWindow,this);
so it is possible to end-user click several times on a button and many windows can open.
is there any way to avoid opening a windows while it is running?
for more information:
lets I click on a button which is open window1. I want to:
Replace WINDOWNAME with the name of the desired Window: 
bool isWindowOpen = false;
foreach (Window w in Application.Current.Windows)
{
    if (w is WINDOWNAME)
    {
        isWindowOpen = true;
        w.Activate();
    }
}
if (!isWindowOpen)
{
    WINDOWNAME newwindow = new WINDOWNAME();
    newwindow.Show();
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With