How to detect the event click button in class A and the click is implemented in Class B

Shay Wilner 1,746 Reputation points
2023-06-30T11:46:47.8366667+00:00

Hello

i have class A and class B and class data

Class B
{
  data Data
  Public B( data thedata) 
{
   this.Data = thedata
}
//btn is a button
 btn.Click += (o, e) =>
            {
               Data.idKey = Convert.ToInt32(btn.Tag);
            };
}

Class A

How to inform to Class A that button in class B was clicked ?

Thanks

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,380 questions
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 50,126 Reputation points Microsoft External Staff
    2023-07-03T02:54:31.02+00:00

    Hello,

    In Xamarin, for cross-class message notifications, Xamarin officially provides the MessageCenter API to achieve this requirement.

    Please refer to the official documentation and examples below:

    Best Regards,

    Alec Liu.


    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.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

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