Update content between tabs

mrizoiwe98 66 Reputation points
2021-03-27T16:35:04.587+00:00

Hello i am using a tabbed app and I have a button in one tab, and I'm not sure how to do it that when the user presses it I want to update content in another tab. I tried experimenting with binding but I couldn't figure it out.

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

Accepted answer
  1. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,751 Reputation points
    2021-03-29T02:27:35.72+00:00

    Hello,

    Welcome to Microsoft Q&A!

    You can simply use MessagingCenter, it is a publish-subscribe pattern, allowing message-based communication between components that are inconvenient to link by object and type references.

    Send in Button Click event

       private void Button_Clicked(object sender, EventArgs e)  
       {  
            MessagingCenter.Send<object>(this, "Hi");  
       }  
    

    Subscribe in another tab(page)

       public Page3()  
       {  
            InitializeComponent();   
            MessagingCenter.Subscribe<object>(this, "Hi", (o) => {   
                        //do something  
             });  
        }  
    

    If the response is helpful, please click "Accept Answer" and upvote it.
    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