Share via

Passing multiple parameters with MessagingCenter

Anonymous
2022-06-03T21:13:35.82+00:00

Hi,

I got this from the Microsoft KB that allows to pass a parameter through MessagingCenter

MessagingCenter.Send<object, string>(this, App.ShowPINActivation, email_address);

but how can I pass two parameters like this:

MessagingCenter.Send<object, string>(this, App.ShowPINActivation, email_address, token_number);

and how to read them in the MessagingCenter.Subscribe?

Thanks,
Jassim

Developer technologies | .NET | Xamarin
Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Viorel 127K Reputation points
    2022-06-04T03:47:55.317+00:00

    Use a tuple, or try defining a class for your data. For example:

    class MyData
    {
       public string Email;
       public int Token;
    }
    . . .
    var d = new MyData { Email = email_address, Token = token_number };
    MessagingCenter.Send(this, App.ShowPINActivation, d);
    

    Show details if you cannot read these data in callbacks.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.