Skip to content

Commit

Permalink
Use instance when using navigationservice
Browse files Browse the repository at this point in the history
  • Loading branch information
martijn00 committed Jul 17, 2017
1 parent b0a41a8 commit b063837
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
Expand Up @@ -18,6 +18,9 @@ public static class MvxPresenterHelpers
{
public static IMvxViewModel LoadViewModel(MvxViewModelRequest request)
{
if(request is MvxViewModelInstanceRequest instanceRequest)
return instanceRequest.ViewModelInstance;

var viewModelLoader = Mvx.Resolve<IMvxViewModelLoader>();
var viewModel = viewModelLoader.LoadViewModel(request, null);
return viewModel;
Expand Down
8 changes: 7 additions & 1 deletion TestProjects/Forms/MvxBindings/MvxBindingsExample/App.cs
Expand Up @@ -18,7 +18,13 @@ public override void Initialize()
.RegisterAsLazySingleton();

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()
Expand Down
4 changes: 2 additions & 2 deletions 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
{
Expand Down
Expand Up @@ -44,6 +44,7 @@
</Compile>
<Compile Include="Services\TextProviderBuilder.cs" />
<Compile Include="ViewModels\MainViewModel.cs" />
<Compile Include="AppStart.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Pages\MainPage.xaml">
Expand Down

0 comments on commit b063837

Please sign in to comment.