Exemplo n.º 1
0
        private Window GetWindowWithDataContext(string windowName)
        {
            Window window = null;

            if (_windowTypes.ContainsKey(windowName))
            {
                var windowType = _windowTypes[windowName];
                if (windowType == null)
                {
                    throw new InvalidOperationException(
                              $"{windowName} not found!");
                }
                window = Activator.CreateInstance(windowType) as Window;
            }
            if (window == null)
            {
                throw new InvalidOperationException(
                          $"{windowName} failed to activate!");
            }
            window.DataContext = _viewModelLocator.GetViewModel(windowName);
            return(window);
        }