Hello,
Firstly, please install CommunityToolkit.Mvvm nugget package.
Then please create a class in your SharedCode project like following code.
public class Game1Message : ValueChangedMessage<Game1>
{ public Game1Message(Game1 game1) : base(game1)
{
}
}
Send the message like following code and delete MessagingCenter.Send<Game1>(this, "Hi");
line. Note:Based on your Game1
generic, I send the Game Object for testing.
Game1 game1= new Game1();
WeakReferenceMessenger.Default.Send(new Game1Message(game1));
Open ViewDidLoad
method, replace MessagingCenter.Subscribe
with the following code.
WeakReferenceMessenger.Default.Register<Game1Message>(this, (r, m) =>
{
// Handle the message here, with r being the recipient and m being the
// input message. Using the recipient passed as input makes it so that
// the lambda expression doesn't capture "this", improving performance.
G_RemoveLogoTestMyView();
});
Here is a document about Sending and receiving messages
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.