The window manager can now also create just view models (without immediately binding a view); added MultiPageViewModel as a base class for the common case of view models that embed multi pages they can switch between; added missing copyright statement for the late checked synchronization context

git-svn-id: file:///srv/devel/repo-conversion/nuwi@49 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
Markus Ewald 2019-02-13 10:30:19 +00:00
parent a17926d02e
commit 2b908f18eb
4 changed files with 60 additions and 1 deletions

View File

@ -76,6 +76,7 @@
<Compile Include="Source\ViewModels\DialogViewModel.Test.cs"> <Compile Include="Source\ViewModels\DialogViewModel.Test.cs">
<DependentUpon>DialogViewModel.cs</DependentUpon> <DependentUpon>DialogViewModel.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Source\ViewModels\MultiPageViewModel.cs" />
<Compile Include="Source\ViewModels\ThreadedAction.cs" /> <Compile Include="Source\ViewModels\ThreadedAction.cs" />
<Compile Include="Source\ViewModels\ThreadedAction.Test.cs"> <Compile Include="Source\ViewModels\ThreadedAction.Test.cs">
<DependentUpon>ThreadedAction.cs</DependentUpon> <DependentUpon>ThreadedAction.cs</DependentUpon>
@ -157,6 +158,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Resources\" /> <Folder Include="Resources\" />
<Folder Include="Source\Controls\" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@ -70,6 +70,24 @@ namespace Nuclex.Windows.Forms {
Control CreateView<TViewModel>(TViewModel viewModel = null) Control CreateView<TViewModel>(TViewModel viewModel = null)
where TViewModel : class; where TViewModel : class;
/// <summary>Creates a view model without a matching view</summary>
/// <typeparam name="TViewModel">Type of view model that will be created</typeparam>
/// <returns>The new view model</returns>
/// <remarks>
/// <para>
/// This is useful if a view model needs to create child view models (i.e. paged container
/// and wants to ensure the same dependency injector (if any) if used as the window
/// manager uses for other view models it creates.
/// </para>
/// <para>
/// This way, view models can set up their child view models without having to immediately
/// bind a view to them. Later on, views can use the window manager to create a matching
/// child view and store it in a container.
/// </para>
/// </remarks>
TViewModel CreateViewModel<TViewModel>()
where TViewModel : class;
} }
} // namespace Nuclex.Windows.Forms } // namespace Nuclex.Windows.Forms

View File

@ -1,4 +1,24 @@
using System; #region CPL License
/*
Nuclex Framework
Copyright (C) 2002-2019 Nuclex Development Labs
This library is free software; you can redistribute it and/or
modify it under the terms of the IBM Common Public License as
published by the IBM Corporation; either version 1.0 of the
License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
IBM Common Public License for more details.
You should have received a copy of the IBM Common Public
License along with this library
*/
#endregion
using System;
using System.ComponentModel; using System.ComponentModel;
using System.Windows.Forms; using System.Windows.Forms;

View File

@ -239,6 +239,25 @@ namespace Nuclex.Windows.Forms {
return viewControl; return viewControl;
} }
/// <summary>Creates a view model without a matching view</summary>
/// <typeparam name="TViewModel">Type of view model that will be created</typeparam>
/// <returns>The new view model</returns>
/// <remarks>
/// <para>
/// This is useful if a view model needs to create child view models (i.e. paged container
/// and wants to ensure the same dependency injector (if any) if used as the window
/// manager uses for other view models it creates.
/// </para>
/// <para>
/// This way, view models can set up their child view models without having to immediately
/// bind a view to them. Later on, views can use the window manager to create a matching
/// child view and store it in a container.
/// </para>
/// </remarks>
public TViewModel CreateViewModel<TViewModel>() where TViewModel : class {
return (TViewModel)CreateInstance(typeof(TViewModel));
}
/// <summary>Locates the view that will be used to a view model</summary> /// <summary>Locates the view that will be used to a view model</summary>
/// <param name="viewModelType"> /// <param name="viewModelType">
/// Type of view model for which the view will be located /// Type of view model for which the view will be located