【发布时间】:2021-03-21 00:57:54
【问题描述】:
我有一个这样的 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();
}
}
我的问题是如何将字符串用户名传递给其他页面?这是一个例子。
public partial class PatientConditions : ContentPage
{
public PatientConditions(string username)
{
InitializeComponent();
}
}
【问题讨论】:
-
如果这是一个在整个应用程序中保持一致和共享的值,那么在 App 对象上创建一个在所有页面上都可见的属性可能更有意义
-
不是,只是这些页面。
-
用代码而不是 XAML 创建页面。或者为内容页面将继承的标签页创建一个 VM
-
你能给我看看这个@Jason的例子吗
标签: c# xamarin.forms tabbedpage