为什么我在ContentPage中创建的变量为空
ReceiptPage.xaml.cs
using System;
using System.Collections.Generic;
using Xamarin.Forms;
namespace LiquidCalc
public partial class ReceiptPage : ContentPage
{
public string OutAromaProp { get; set; }
public string OutShotProp { get; set; }
public string OutBasisProp { get; set; }
public ReceiptPage()
{
InitializeComponent();
BindingContext = this;
OutAroma.Text = "Hallo:"+ OutAromaProp;
}
}
在主页上
var page = new ReceiptPage
{
OutAromaProp ="Hallo", //"Aroma: " + AromaOut.ToString() + " ml",
OutShotProp = "Nikotien Shot " + NikoteinMG.Text + "mg: " + Math.Round(NikoteinShot).ToString() + " ml",
OutBasisProp = "Basis: " + Math.Round(Basis).ToString() + "ml",
};
await Navigation.PushModalAsync(page,true);
标签仅获得值“ Hallo:”,未分配变量OutAromaProp。 为什么?
答案 0 :(得分:0)
好的,我有它,它不会因为异步原因而工作。 这个解决了我的问题
protected override void OnAppearing()
{
base.OnAppearing();
OutAroma.Text = OutAromaProp;
OutShot.Text = OutShotProp;
OutBasis.Text = OutBasisProp;
}