Created
November 25, 2018 02:33
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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