Hi Im trying to send multiple entries with messeging center but couldnt manage it (im new on xamarin and couldnt found proper examples for my code) im trying to idenify messages on confirm page (_entry1 you will go here _entry2 you will go there)
InformationPage Xaml
<Label Text="Please Type Informations Needed" Margin="35" HorizontalOptions="Center"/>
<Entry x:Name="_entry1" Placeholder="Info 1"/>
<Entry x:Name="_entry2" Placeholder="Info 2"/>
<Button Text="Send Information" BackgroundColor="Crimson" TextColor="White" Clicked="SendInformation"/>
InformationPage CS
private void SendInformation(object sender, EventArgs e)
{
Navigation.PushAsync(new ConfirmPage());
MessagingCenter.Send(this, "EnteryValue", _entry1.Text);
MessagingCenter.Send(this, "EnteryValue", _entry2.Text);
}
ConfirmPage CS
MessagingCenter.Subscribe<InformationPage, string>(this, "EnteryValue", (page, value) =>
{
_confirm.Text = value;
MessagingCenter.Unsubscribe<InformationPage, string>(this, "EnteryValue");
});
There is no need to use MessagingCenter in your case, it usually use when publishers send messages without having knowledge of any receivers:
The quickest way to pass value when you navigation to next page is passing them with the constructor of
ConfirmPage:In
InformationPagewhen you navigate, pass values:In ConfirmPage, receive values: