C# 同一页上有多个bindingContext

C# 同一页上有多个bindingContext,c#,xamarin,binding-context,C#,Xamarin,Binding Context,我将listview与headerTemplate一起使用。 我需要创建一个bindableproperty来将文本添加到模板中 因此,我在headertemplate“MyMenuHeader”中创建了一个可绑定属性: 在我的listview中,我尝试使用“set value”设置此属性: 但我的属性已设置,但从未显示在标签中 致以最良好的祝愿 编辑:我有一个新参数bindableproperty.create public static readonly BindableProperty

我将listview与headerTemplate一起使用。 我需要创建一个bindableproperty来将文本添加到模板中

因此,我在headertemplate“MyMenuHeader”中创建了一个可绑定属性:

在我的listview中,我尝试使用“set value”设置此属性:

但我的属性已设置,但从未显示在标签中

致以最良好的祝愿

编辑:我有一个新参数bindableproperty.create

 public static readonly BindableProperty TitleTextProperty =
 BindableProperty.Create("TitleText", typeof(String), typeof(MyRelaiTabCell), null, propertyChanged: OnTitleTextChanged);

        public String TitleText
        {
            get { return (String)GetValue(TitleTextProperty); }
            set { SetValue(TitleTextProperty, value); }
        }
此函数用于在属性更改时修改标签的值:

static void OnTitleTextChanged(BindableObject bindable, object oldValue, object newValue)
{
    var menu = (bindable as MyRelaiTabCell);
    // Property changed implementation goes here
    menu._titleText.SetValue(Label.TextProperty, (newValue as String));
}

这是工作,但只有一种方式。视图模型-->视图单元。所以当我设置值时。当我试图在更改时获取价值时,我没有相关信息。

您将标签添加到何处查看?我看到它是创建的,但没有添加任何内容。您在哪里添加标签以查看?我看到它被创建了,但没有添加到任何地方
 public static readonly BindableProperty TitleTextProperty =
 BindableProperty.Create("TitleText", typeof(String), typeof(MyRelaiTabCell), null, propertyChanged: OnTitleTextChanged);

        public String TitleText
        {
            get { return (String)GetValue(TitleTextProperty); }
            set { SetValue(TitleTextProperty, value); }
        }
static void OnTitleTextChanged(BindableObject bindable, object oldValue, object newValue)
{
    var menu = (bindable as MyRelaiTabCell);
    // Property changed implementation goes here
    menu._titleText.SetValue(Label.TextProperty, (newValue as String));
}