Hey I want to make sure that I can only open ONE instance of this window, it doesn't seem to be working and not sure why.
I'm checking there is already a window open with the same name, and making sure im not detecting this current window attempting to open.
public new void Show() { //Ensure new notifications are placed above older ones foreach (Window window in System.Windows.Application.Current.Windows) { string windowName = window.GetType().Name; if (!windowName.Equals("NotificationAll") && window != this) { this.Topmost = true; base.Show(); this.Owner = System.Windows.Application.Current.MainWindow; //Position the Notification var workingArea = SystemParameters.WorkArea; this.Left = (workingArea.Width - this.ActualWidth) / 2; this.Top = workingArea.Bottom - this.ActualHeight; } } } However more than one window is opening still!
NotificationAllwindow. Remember, that code is inside aforeachloop. Step through it with a debugger and you'll see what I mean.Showfunction seems like it is way too late in the process to enforce a single instance. You can use a static field to track if there is an instance or not, orLazy<T>.