/// <summary>
        /// Shows the document in the main shell.
        /// </summary>
        /// <typeparam name="TViewModel">The type of the view model.</typeparam>
        /// <param name="viewModel">The view model to show which will automatically be resolved to a view.</param>
        /// <param name="tag">The tag.</param>
        /// <param name="dockingSettings">The docking settings.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="viewModel" /> is <c>null</c>.</exception>
        public void ShowContextSensitiveDocument <TViewModel>(TViewModel viewModel, object tag = null, DockingSettings dockingSettings = null)
            where TViewModel : IViewModel
        {
            Argument.IsNotNull("viewModel", viewModel);

            Log.Debug("Showing document for view model '{0}'", viewModel.UniqueIdentifier);

            var viewType = GetViewType(viewModel);

            var document = AvalonDockHelper.FindDocument(viewType, tag);

            if (document == null)
            {
                var view = ViewHelper.ConstructViewWithViewModel(viewType, viewModel);
                document = AvalonDockHelper.CreateDocument(view, tag);
                if (dockingSettings != null)
                {
                    AvalonDockHelper.AddNewDocumentToDockingManager(dockingSettings, document);
                }
            }

            AvalonDockHelper.ActivateDocument(document);

            Log.Debug("Showed document for view model '{0}'", viewModel.UniqueIdentifier);
        }
        /// <summary>
        /// Opens a new document.
        /// </summary>
        /// <typeparam name="TViewModel">The type of the view model.</typeparam>
        /// <param name="viewModel">The view model.</param>
        /// <param name="tag">The tag.</param>
        /// <param name="dockingSettings">The docking settings.</param>
        public void ShowDocument <TViewModel>(TViewModel viewModel, object tag = null, DockingSettings dockingSettings = null)
            where TViewModel : IViewModel
        {
            Argument.IsNotNull("viewModel", viewModel);
            Log.Debug("Opening document for view model '{0}'", viewModel.UniqueIdentifier);

            var document = CreateDocument(viewModel, tag);

            AvalonDockHelper.AddNewDocumentToDockingManager(dockingSettings, document);
            AvalonDockHelper.ActivateDocument(document);
        }
예제 #3
0
        /// <summary>
        /// Shows the document in the main shell.
        /// </summary>
        /// <typeparam name="TViewModel">The type of the view model.</typeparam>
        /// <param name="viewModel">The view model to show which will automatically be resolved to a view.</param>
        /// <param name="tag">The tag.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="viewModel" /> is <c>null</c>.</exception>
        public void ShowDocument <TViewModel>(TViewModel viewModel, object tag = null) where TViewModel : IViewModel
        {
            Argument.IsNotNull("viewModel", viewModel);

            Log.Debug("Showing document for view model '{0}'", viewModel.UniqueIdentifier);

            var viewLocator = GetService <IViewLocator>();
            var viewType    = viewLocator.ResolveView(viewModel.GetType());

            var document = AvalonDockHelper.FindDocument(viewType, tag);

            if (document == null)
            {
                var view = ViewHelper.ConstructViewWithViewModel(viewType, viewModel);
                document = AvalonDockHelper.CreateDocument(view, tag);
            }

            AvalonDockHelper.ActivateDocument(document);

            Log.Debug("Showed document for view model '{0}'", viewModel.UniqueIdentifier);
        }
 protected override void Execute(object parameter)
 {
     AvalonDockHelper.ActivateDocument <PresetExportListViewModel>();
     base.Execute(parameter);
 }