In Windows Phone 8.1 there is any way to navigate from one page to another using an string instead of a Type?
There is no reflection and Frame.Navigate only accepts type.
Thank you.
In Windows Phone 8.1 there is any way to navigate from one page to another using an string instead of a Type?
There is no reflection and Frame.Navigate only accepts type.
Thank you.
I agree with Kai Brummund. You should write a NavigationService. A good example of a navigation service is the MVVM light navigation service. Here you can find the source code.
Or... you just can use MVVMLight which comes with an integrated NavigationService (INavigationService). You set it in ViewModelLocator like this:
private const string URL_DETALLE = "/View/DetalleView.xaml";
public ViewModelLocator()
{
// ...
var navigationService = this.CreateNavigationService();
if (!SimpleIoc.Default.IsRegistered<INavigationService>())
{
SimpleIoc.Default.Register<INavigationService>(() => navigationService);
}
//...
}
private INavigationService CreateNavigationService()
{
var navigationService = new NavigationService();
navigationService.Configure(URL_DETALLE, typeof(DetalleView));
return navigationService;
}
Then in your VM constructor you will recieve this navigaton service and you can use it this way:
private INavigationService navigationService;
public DetalleViewModel(INavigationService navigationService)
{
this.navigationService = navigationService;
this.navigationService.NavigateTo(ViewModelLocator.URL_DETALLE);
}
Hope it helps ;)
© 2022 - 2024 — McMap. All rights reserved.
NavigationService
ot some sort is generally a good idea, and you should go for it. I'm pretty sure you can also use Reflection, though, if you need to. – Septuplet