嗨,我正在尝试使用消息中心发送多个条目,但无法管理它(我是 xamarin 的新手,找不到适合我的代码的示例)我试图在确认页面上识别消息(_entry1 你会去这里 _entry2 你会去那里)
信息页 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"/>
信息页 CS
private void SendInformation(object sender, EventArgs e)
{
Navigation.PushAsync(new ConfirmPage());
MessagingCenter.Send(this, "EnteryValue", _entry1.Text);
MessagingCenter.Send(this, "EnteryValue", _entry2.Text);
}
确认页面 CS
MessagingCenter.Subscribe<InformationPage, string>(this, "EnteryValue", (page, value) =>
{
_confirm.Text = value;
MessagingCenter.Unsubscribe<InformationPage, string>(this, "EnteryValue");
});