WindowManager and Singleton Windows

Topics: Framework Services, UI Architecture
Jun 15, 2012 at 8:50 PM

I have a window in my application which is configured as a singleton


Now, If I have a functon

public void OpenLogWindow() {  

and when a user calls this function multiple times, you get multiple views opening. (All bound to the same view model)

I only want one window to appear. Subsequent calls to this function should act as a BringToFront.

I'm just wondering how other people have dealt with this situation?


I was thinking something along the lines of:

public class WindowManagerExtended : WindowManager, IWindowManagerExtended
        private readonly List<object> openWindows = new List<object>();

        public void ShowSingletonWindow(object rootModel, object context = null, IDictionary<string, object> settings = null)
            ViewModelBase viewModel = rootModel as ViewModelBase;

            if (openWindows.Contains(rootModel))
                // TODO figure out a way to bring this view to front?

            if (viewModel != null)
                viewModel.Deactivated += this.ViewModelDeactivated;

            this.ShowWindow(rootModel, context, settings);

        private void ViewModelDeactivated(object sender, DeactivationEventArgs e)

I'm currently unsure how I will get that window to "bring to front" but I figure it should be doable.


Any thoughts?





Jun 15, 2012 at 8:51 PM

I forgot to mention that I was also looking at using a Conductor, but it appears that this is more designed for ContentControls rather than popup windows.