我有一个这样的TappedPage:
<?xml version="1.0" encoding="UTF-8"?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="using:MyApp" x:Class="MyApp.AccountPatientPage" Title="Account">
<local:PatientConditions IconImageSource="user.png" />
<local:PatientPainKillers IconImageSource="user.png" />
<local:PatientPainStory IconImageSource="user.png" />
</TabbedPage>下面是后面的代码:
public partial class PatientProfilePage : TabbedPage
{
public PatientProfilePage(string username)
{
InitializeComponent();
}
}我的问题是如何将字符串username传递给其他页面?这里有一个例子。
public partial class PatientConditions : ContentPage
{
public PatientConditions(string username)
{
InitializeComponent();
}
}发布于 2020-12-10 00:20:55
除非您以不同的方式指定,否则页面将继承其父页面的BindingContext
// some custom class that contains properties for username and anything
// else you need
MyViewModel vm;
public PatientProfilePage(string username)
{
InitializeComponent();
this.BindingContext = vm = new MyViewModel(username);
}https://stackoverflow.com/questions/65220366
复制相似问题