【发布时间】:2015-02-19 20:03:29
【问题描述】:
我在项目中使用 Mvvmlight INavigationService,从视图模型导航到视图,并将对象作为参数传递,我如何在视图模型或后面的代码中获取。
I have implemented based on this
我的视图模型定位器
private static INavigationService CreateNavigationService()
{
var navigationService = new NavigationService();
navigationService.Configure("topupdetails", new System.Uri("/Views/TopUpDetails.xaml", System.UriKind.Relative));
return navigationService;
}
查看模型命令执行
private void OnTapCommand(MyModel tappedItem)
{
if (tappedItem._verified)
{
SimpleIoc.Default.GetInstance<INavigationService>().NavigateTo("topupdetails",tappedItem);
}
我导航到的页面
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (NavigationContext.QueryString.Any())
{
var item = NavigationContext.QueryString.Values.First();
}
base.OnNavigatedTo(e);
}
在查询字符串中,我只是像“e-fghfdsfsd”这样的值,但不能转换为我的类对象,我可以在视图模型或代码隐藏中获取值,这是执行此操作的最佳方法,代码最少在代码隐藏中?
Mvvmlight 版本:Mvvmlight 5 Laurent Mvvmlight 5 Announcement
【问题讨论】:
标签: c# windows-phone-8 mvvm mvvm-light