Suggestion for UIVisualizer

Jan 14, 2011 at 6:08 PM

Hi! First, I need to thank you for this great work! Let's go.

I changed my copy of UIVisualizer, to add a new paremeter in Show method. Now its working like this:

        public bool Show(string key, object state, Window owner, EventHandler<UICompletedEventArgs> completedProc)
            Window win = CreateWindow(key, state, false, completedProc, false);
            if (win != null)
                win.Owner = owner;
                return true;
            return false;

I needed this to pass a owner for a window called by another window.  Before that change,  when Window1 called Window2 and Window2 got closed, sometimes main application lost focus. The solution I found was that. Now, my ViewModel has a property  Window Owner. Unhappily in Load event of Window using this ViewModel, I have to access it and pass:

            if (DataContext != null && DataContext is MyTypeofViewModel)
                var vm = DataContext as MyTypeofViewModel;
                vm.ViewOwner = this;


Do you have some design consideration, or, you can suggest me a different approach I'm not seeing here.

Thank you