Exemple #1
0
        private void OpenWindow(OpenWindowMessage message)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            try
            {
                var window = base.OwnedWindows
                             .Cast <Window>()
                             .Where(w => w.DataContext == message.DataContext)
                             .FirstOrDefault();

                if (window == null)
                {
                    string windowName = message.WindowName;
                    if (!windowName.EndsWith("Window"))
                    {
                        windowName = string.Format("{0}Window", message.WindowName);
                    }

                    if (_windowTypeNameDictionary.ContainsKey(windowName))
                    {
                        var windowType = _windowTypeNameDictionary[windowName];
                        window             = (Window)Activator.CreateInstance(windowType);
                        window.DataContext = message.DataContext;
                        window.Owner       = this;

                        window.Show();
                    }
                }
                else
                {
                    if (!window.IsVisible)
                    {
                        window.Show();
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
                throw;
            }
        }
Exemple #2
0
        private void OpenWindow(OpenWindowMessage message)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            try
            {
                var window = base.OwnedWindows
                    .Cast<Window>()
                    .Where(w => w.DataContext == message.DataContext)
                    .FirstOrDefault();

                if (window == null)
                {
                    string windowName = message.WindowName;
                    if (!windowName.EndsWith("Window"))
                    {
                        windowName = string.Format("{0}Window", message.WindowName);
                    }

                    if (_windowTypeNameDictionary.ContainsKey(windowName))
                    {
                        var windowType = _windowTypeNameDictionary[windowName];
                        window = (Window)Activator.CreateInstance(windowType);
                        window.DataContext = message.DataContext;
                        window.Owner = this;

                        window.Show();
                    }
                }
                else
                {
                    if (!window.IsVisible)
                    {
                        window.Show();
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
                throw;
            }
        }