From b063837e90c31150886a8e4f1d3e3c2fb2d55c1e Mon Sep 17 00:00:00 2001 From: Martijn van Dijk Date: Mon, 17 Jul 2017 16:51:00 +0200 Subject: [PATCH] Use instance when using navigationservice --- .../MvvmCross.Forms/Presenters/MvxPresenterHelpers.cs | 3 +++ TestProjects/Forms/MvxBindings/MvxBindingsExample/App.cs | 8 +++++++- .../Forms/MvxBindings/MvxBindingsExample/AppStart.cs | 4 ++-- .../MvxBindingsExample/MvxBindingsExample.csproj | 1 + 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/MvvmCross-Forms/MvvmCross.Forms/Presenters/MvxPresenterHelpers.cs b/MvvmCross-Forms/MvvmCross.Forms/Presenters/MvxPresenterHelpers.cs index b3b1518f8..3852ed580 100644 --- a/MvvmCross-Forms/MvvmCross.Forms/Presenters/MvxPresenterHelpers.cs +++ b/MvvmCross-Forms/MvvmCross.Forms/Presenters/MvxPresenterHelpers.cs @@ -18,6 +18,9 @@ namespace MvvmCross.Forms.Presenters { public static IMvxViewModel LoadViewModel(MvxViewModelRequest request) { + if(request is MvxViewModelInstanceRequest instanceRequest) + return instanceRequest.ViewModelInstance; + var viewModelLoader = Mvx.Resolve(); var viewModel = viewModelLoader.LoadViewModel(request, null); return viewModel; diff --git a/TestProjects/Forms/MvxBindings/MvxBindingsExample/App.cs b/TestProjects/Forms/MvxBindings/MvxBindingsExample/App.cs index d12f76558..662c2ef53 100644 --- a/TestProjects/Forms/MvxBindings/MvxBindingsExample/App.cs +++ b/TestProjects/Forms/MvxBindings/MvxBindingsExample/App.cs @@ -18,7 +18,13 @@ namespace MvxBindingsExample .RegisterAsLazySingleton(); InitializeText(); - RegisterAppStart(); + + // Construct custom application start object + Mvx.ConstructAndRegisterSingleton(); + var appStart = Mvx.Resolve(); + + // register the appstart object + RegisterAppStart(appStart); } private void InitializeText() diff --git a/TestProjects/Forms/MvxBindings/MvxBindingsExample/AppStart.cs b/TestProjects/Forms/MvxBindings/MvxBindingsExample/AppStart.cs index 199ce5185..f41cad0ad 100644 --- a/TestProjects/Forms/MvxBindings/MvxBindingsExample/AppStart.cs +++ b/TestProjects/Forms/MvxBindings/MvxBindingsExample/AppStart.cs @@ -1,9 +1,9 @@ using System.Threading.Tasks; using MvvmCross.Core.Navigation; using MvvmCross.Core.ViewModels; -using RoutingExample.Core.ViewModels; +using MvxBindingsExample.ViewModels; -namespace RoutingExample.Core +namespace MvxBindingsExample { public class AppStart : IMvxAppStart { diff --git a/TestProjects/Forms/MvxBindings/MvxBindingsExample/MvxBindingsExample.csproj b/TestProjects/Forms/MvxBindings/MvxBindingsExample/MvxBindingsExample.csproj index 10c9700f8..82d7b9a91 100644 --- a/TestProjects/Forms/MvxBindings/MvxBindingsExample/MvxBindingsExample.csproj +++ b/TestProjects/Forms/MvxBindings/MvxBindingsExample/MvxBindingsExample.csproj @@ -44,6 +44,7 @@ +