Use instance when using navigationservice
This commit is contained in:
Родитель
b0a41a84ce
Коммит
b063837e90
|
@ -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">
|
||||||
|
|
Загрузка…
Ссылка в новой задаче