简体   繁体   English

Xlabs-将参数传递给ViewModel

[英]Xlabs - Pass a parameter to ViewModel

Is there a way to pass a parameter to a ViewModel using XLabs and NavigationService? 有没有一种方法可以使用XLabs和NavigationService将参数传递给ViewModel?

The 'args' parameter for the 'NavigateTo' method appears to be destined for the View, not the ViewModel and the 'Initialiser' method parameter on ViewFactory.Register does not seem to receive the arguments either. “ NavigateTo”方法的“ args”参数似乎是针对视图的,而不是ViewFactory上的ViewModel和“ Initialiser”方法参数。Register似乎也没有接收到任何参数。

Thanks, 谢谢,

Scott. 斯科特。

You can do like this: 您可以这样:

//MyOriginViewModel
await Navigation.PushAsync<MyDestinyViewModel>((vm, v) => vm.Init(myVar), false);

//MyDestinyViewModel
public void Init(string myVar)
{
    //
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM