Use instance when using navigationservice

This commit is contained in:
Martijn van Dijk 2017-07-17 16:51:00 +02:00
Родитель b0a41a84ce
Коммит b063837e90
4 изменённых файлов: 13 добавлений и 3 удалений

Просмотреть файл

@ -18,6 +18,9 @@ namespace MvvmCross.Forms.Presenters
{ {
public static IMvxViewModel LoadViewModel(MvxViewModelRequest request) public static IMvxViewModel LoadViewModel(MvxViewModelRequest request)
{ {
if(request is MvxViewModelInstanceRequest instanceRequest)
return instanceRequest.ViewModelInstance;
var viewModelLoader = Mvx.Resolve<IMvxViewModelLoader>(); var viewModelLoader = Mvx.Resolve<IMvxViewModelLoader>();
var viewModel = viewModelLoader.LoadViewModel(request, null); var viewModel = viewModelLoader.LoadViewModel(request, null);
return viewModel; return viewModel;

Просмотреть файл

@ -18,7 +18,13 @@ namespace MvxBindingsExample
.RegisterAsLazySingleton(); .RegisterAsLazySingleton();
InitializeText(); InitializeText();
RegisterAppStart<MainViewModel>();
// Construct custom application start object
Mvx.ConstructAndRegisterSingleton<IMvxAppStart, AppStart>();
var appStart = Mvx.Resolve<IMvxAppStart>();
// register the appstart object
RegisterAppStart(appStart);
} }
private void InitializeText() private void InitializeText()

Просмотреть файл

@ -1,9 +1,9 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using MvvmCross.Core.Navigation; using MvvmCross.Core.Navigation;
using MvvmCross.Core.ViewModels; using MvvmCross.Core.ViewModels;
using RoutingExample.Core.ViewModels; using MvxBindingsExample.ViewModels;
namespace RoutingExample.Core namespace MvxBindingsExample
{ {
public class AppStart : IMvxAppStart public class AppStart : IMvxAppStart
{ {

Просмотреть файл

@ -44,6 +44,7 @@
</Compile> </Compile>
<Compile Include="Services\TextProviderBuilder.cs" /> <Compile Include="Services\TextProviderBuilder.cs" />
<Compile Include="ViewModels\MainViewModel.cs" /> <Compile Include="ViewModels\MainViewModel.cs" />
<Compile Include="AppStart.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Pages\MainPage.xaml"> <EmbeddedResource Include="Pages\MainPage.xaml">