locked
How to use the Messaging center RRS feed

  • Question

  • User397066 posted

    Dear Techie,

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

    Thanks in advance, Vasanth

    Sunday, February 14, 2021 4:08 PM

Answers

  • User379860 posted

    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 SelectedModels=new List(); 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.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, February 15, 2021 7:24 AM