Forum Xamarin.Forms


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.

Messaging Centre with Method

Vasanthakumar06Vasanthakumar06 Member ✭✭✭
edited February 18 in Xamarin.Forms

Hi Techie,
How to call method inside the messaging center with returning parameter.

 private async void BtnRegistration_Clicked(object sender, EventArgs e)
            string image = "Deafult.jpeg";
            MessagingCenter.Subscribe<App, List<Model>>(App.Current, "OneMessage", async (snd, arg) =>
                 Model model = arg.FirstOrDefault<Model>();
                 txtName.Text = model.Group_Name;
                 image = model.ImagePath;
                    var accessToken = Settings.AccessToken;
            var client = new HttpClient();
            string Groupname = txtName.Text;

            var json = JsonConvert.SerializeObject(models);
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(
                 "Bearer", accessToken);

            HttpContent content = new StringContent(json);
            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            var response =await client.PostAsync("API CALL ", content);


            BtnRegistration.IsEnabled = true;


Sign In or Register to comment.