Forum Cross Platform with Xamarin

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

How to use the Messaging center

Dear Techie,

How to use the messaging center to return the list of model to Nextpage.cs

Thanks in advance,
Vasanth

Best Answer

  • LeonLuLeonLu Member, Xamarin Team Xamurai
    Accepted Answer

    Based on your Nextpage.cs in previous link, please make following test. I pop up window in BtnRegistration_Clicked ,

     public partial class Nextpage : ContentPage
        {
            List<Model> SelectedModels=new List<Model>();
            public Nextpage()
            {
                InitializeComponent();
    
    
                MessagingCenter.Subscribe<App, List<Model>>(App.Current, "OneMessage", (snd, arg) =>
                {
                    Model model = arg.FirstOrDefault<Model>();
                    txtName.Text = model.profile_name;
                    txtEmail.Text = model.user_id;
    
    
                });
            }
    
            protected override void OnAppearing()
            {
                base.OnAppearing();
    
            }
    
            private async void BtnRegistration_Clicked(object sender, EventArgs e)
            {
                await Navigation.PushPopupAsync(new Tagfriends());
            }
    
            private void BtnUpdate_Clicked(object sender, EventArgs e)
            {
    
            }
    
            private void txtAddress_Focused(object sender, FocusEventArgs e)
            {
    
            }
        }
    }
    

    then popup the Taggingfriend page, click the button click event, back to the Nextpage, please copy my code completely to make a test.

     private async void Button_Clicked(object sender, EventArgs e)
            {
    
                List<Model>  result = Models.Where(w => w.IsChecked == true).ToList();
    
    
                MessagingCenter.Send<App, List<Model>>((App)App.Current, "OneMessage", result);
    
    
    
                await Navigation.PopPopupAsync();
            }
    

    Xamarin forums are migrating to a new home on Microsoft Q&A!
    We invite you to post new questions in the Xamarin forums’ new home on Microsoft Q&A!
    For more information, please refer to this sticky post.

Answers

  • LeonLuLeonLu Member, Xamarin Team Xamurai
    Accepted Answer

    Based on your Nextpage.cs in previous link, please make following test. I pop up window in BtnRegistration_Clicked ,

     public partial class Nextpage : ContentPage
        {
            List<Model> SelectedModels=new List<Model>();
            public Nextpage()
            {
                InitializeComponent();
    
    
                MessagingCenter.Subscribe<App, List<Model>>(App.Current, "OneMessage", (snd, arg) =>
                {
                    Model model = arg.FirstOrDefault<Model>();
                    txtName.Text = model.profile_name;
                    txtEmail.Text = model.user_id;
    
    
                });
            }
    
            protected override void OnAppearing()
            {
                base.OnAppearing();
    
            }
    
            private async void BtnRegistration_Clicked(object sender, EventArgs e)
            {
                await Navigation.PushPopupAsync(new Tagfriends());
            }
    
            private void BtnUpdate_Clicked(object sender, EventArgs e)
            {
    
            }
    
            private void txtAddress_Focused(object sender, FocusEventArgs e)
            {
    
            }
        }
    }
    

    then popup the Taggingfriend page, click the button click event, back to the Nextpage, please copy my code completely to make a test.

     private async void Button_Clicked(object sender, EventArgs e)
            {
    
                List<Model>  result = Models.Where(w => w.IsChecked == true).ToList();
    
    
                MessagingCenter.Send<App, List<Model>>((App)App.Current, "OneMessage", result);
    
    
    
                await Navigation.PopPopupAsync();
            }
    

    Xamarin forums are migrating to a new home on Microsoft Q&A!
    We invite you to post new questions in the Xamarin forums’ new home on Microsoft Q&A!
    For more information, please refer to this sticky post.

Sign In or Register to comment.