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)
|
||||
{
|
||||
if(request is MvxViewModelInstanceRequest instanceRequest)
|
||||
return instanceRequest.ViewModelInstance;
|
||||
|
||||
var viewModelLoader = Mvx.Resolve<IMvxViewModelLoader>();
|
||||
var viewModel = viewModelLoader.LoadViewModel(request, null);
|
||||
return viewModel;
|
||||
|
|
|
@ -18,7 +18,13 @@ namespace MvxBindingsExample
|
|||
.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()
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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">
|
||||
|
|
Загрузка…
Ссылка в новой задаче