1

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 :)

  • 1
    "not working" is not a useful description of the problem. Do you get an error or exception? Have you stepped through the code in the debugger to verify that your command is executing? Have you checked the log for any useful messages? – Jason May 01 '22 at 19:54
  • 1
    There is a method "Init" to handle the parameters, not in the constructor, [check this](https://github.com/rid00z/FreshMvvm/blob/3ccf13b0b506b6e7193cdadde1d988ac76ac6889/src/FreshMvvm/FreshBasePageModel.cs#L52-L58) – Shaw May 01 '22 at 21:35

1 Answers1

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;
        ...
    }
}
ToolmakerSteve
  • 18,547
  • 14
  • 94
  • 196