Scott Simms
Scott Simms

Reputation: 55

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.

Upvotes: 1

Views: 602

Answers (1)

rubStackOverflow
rubStackOverflow

Reputation: 6173

You can do like this:

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

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

Upvotes: 0

Related Questions