Пример #1
0
        /// <summary>
        /// Shows window with content
        /// </summary>
        /// <typeparam name="TView">type of UserControl class to show content</typeparam>
        /// <param name="viewmodel">DataContext of the view</param>
        public static TView ShowWindow <TView>(ViewmodelBase viewmodel) where TView : Window, new()
        {
            var newWindow = new TView
            {
                Owner       = Application.Current.MainWindow,
                DataContext = viewmodel
            };

            newWindow.Show();
            return(newWindow);
        }
Пример #2
0
        /// <summary>
        /// Shows modal dialog with content
        /// </summary>
        /// <typeparam name="TView">type of UserControl class to show content</typeparam>
        /// <param name="viewmodel">DataContext of the view</param>
        public static bool?ShowDialog <TView>(ViewmodelBase viewmodel)
            where TView : Window, new()
        {
            var newWindow = new TView
            {
                Owner = Application.Current.MainWindow,
                WindowStartupLocation = WindowStartupLocation.CenterOwner,
                DataContext           = viewmodel
            };

            return(newWindow.ShowDialog());
        }