首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Xamarin Forms - TabbedPage - Pass参数

Xamarin Forms - TabbedPage - Pass参数
EN

Stack Overflow用户
提问于 2020-12-10 00:01:35
回答 1查看 72关注 0票数 0

我有一个这样的TappedPage:

代码语言:javascript
复制
<?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>

下面是后面的代码:

代码语言:javascript
复制
public partial class PatientProfilePage : TabbedPage
    {
        public PatientProfilePage(string username)
        {
            InitializeComponent();
        }
    }

我的问题是如何将字符串username传递给其他页面?这里有一个例子。

代码语言:javascript
复制
public partial class PatientConditions : ContentPage
    {
        public PatientConditions(string username)
        {
            InitializeComponent();
        }
    }
EN

回答 1

Stack Overflow用户

发布于 2020-12-10 00:20:55

除非您以不同的方式指定,否则页面将继承其父页面的BindingContext

代码语言:javascript
复制
// 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);
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65220366

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档