private void LocationBtn_Clicked(object sender, EventArgs e) { LocationModel stringInThisCell = (LocationModel)((Button)sender).BindingContext; System.Diagnostics.Debug.WriteLine("send msg current update = " + stringInThisCell.ToLocation); string source = stringInThisCell.ToLocation; string result = "XYZ"; string[] values = { source, result }; MessagingCenter.Send <LoadItemPutawayTemplate, string[]>(this, "Location", values); }
public MainPage() { InitializeComponent(); WorkItems = new List <LocationModel>(); WorkItems.Add(new LocationModel { ToLocation = "Tomato" }); WorkItems.Add(new LocationModel { ToLocation = "Zucchini" }); WorkItems.Add(new LocationModel { ToLocation = "Tomato2" }); WorkItems.Add(new LocationModel { ToLocation = "Romaine2" }); WorkItems.Add(new LocationModel { ToLocation = "Zucchin2" }); MessagingCenter.Subscribe <LoadItemPutawayTemplate, string[]>(this, "Location", async(sender, values) => { string source = values[0]; string result = values[1]; System.Diagnostics.Debug.WriteLine("receive message current update = " + source + " ----- " + result); for (int i = 0; i < WorkItems.Count; i++) { LocationModel model = WorkItems[i]; if (source.Equals(model.ToLocation)) { model.ToLocation = result; break; } } }); workList.ItemsSource = WorkItems; // ItemsSource="{ Binding WorkItems}" }