'In Xamarin Forms application in MVVM, i use FreshMvvm framework and want to navigate to targetPageModel and pass data from commandParameter
xaml extract :
<Button ... Command="{Binding NextPageButtonCommand, Mode=OneWay}" CommandParameter="wallet" />
In This code command callback with parameter works well :
NextPageButtonCommand = new Command<string>(parameter => Debug.WriteLine(parameter));
But with this this code with async and PushPageModel is not working...
NextPageButtonCommand = new Command<string>(async typeOfCase => await CoreMethods.PushPageModel<TargetPageModel>(typeOfCase));
TargetPageModel
public class TargetPageModel : FreshBasePageModel
{
public TargetPageModel(string parameter)
{
CreateYourCodeText = "Créez votre code :";
}
}
Thank you for your help :)
Solution 1:[1]
Expanding on Shaw's comment:
At FreshMvvm Important Methods, see public virtual void Init(object initData) { }.
Override that method, to use the data you pass in. Something like:
public class TargetPageModel : FreshBasePageModel
{
...
public override void Init(object initData)
{
var typeOfCase = (string)initData;
...
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
