简体   繁体   中英

Xlabs - Pass a parameter to ViewModel

Is there a way to pass a parameter to a ViewModel using XLabs and NavigationService?

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.

Thanks,

Scott.

You can do like this:

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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