protected virtual FrameworkElement CreateWindow(object vm) { Window w; if (WindowFactory != null) { w = (Window)WindowFactory.LoadContent(); } else { w = new Window(); } w.WindowStartupLocation = WindowStartupLocation; if (WindowStyle != null) { w.Style = WindowStyle; } if (WindowStyleSelector != null) { w.Style = WindowStyleSelector.SelectStyle(vm, w); } if (SetWindowOwner && !IsMainWindow && AssociatedObject is FrameworkElement) { ViewServiceBase.UpdateWindowOwner(w, (FrameworkElement)AssociatedObject); } if (!IsMainWindow && AssociatedObject is FrameworkElement) { ViewServiceBase.UpdateThemeName(w, (FrameworkElement)AssociatedObject); } if (IsMainWindow) { Application.Current.MainWindow = w; } return(w); }