Skip to content

Instantly share code, notes, and snippets.

@juucustodio
Created November 25, 2018 02:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juucustodio/fd5f0aa3aa57ab6f2c729d3b1feb1f33 to your computer and use it in GitHub Desktop.
Save juucustodio/fd5f0aa3aa57ab6f2c729d3b1feb1f33 to your computer and use it in GitHub Desktop.
Example of how to use MessagingCenter in Xamarin.Forms applications. - https://julianocustodio.com/messagingcenter
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Xamarin.Forms;
namespace DemoMessagingCenter
{
public partial class ListPage : ContentPage
{
ObservableCollection<string> list = new ObservableCollection<string>();
public ListPage()
{
InitializeComponent();
ListItem.ItemsSource = list;
MessagingCenter.Subscribe<Message>(this, "AddItem", message => {
list.Add(message.Value);
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment