Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何绑定到viewmodel上不是当前绑定上下文的属性_C#_Forms_Xamarin_Binding - Fatal编程技术网

C# 如何绑定到viewmodel上不是当前绑定上下文的属性

C# 如何绑定到viewmodel上不是当前绑定上下文的属性,c#,forms,xamarin,binding,C#,Forms,Xamarin,Binding,我有一个标签: <Label BindingContext="{Binding BModel}" Text="{Binding BoundDataItem.CurrentValue.Value}" IsVisible="{Binding IsEditButtonShown}"/> 什么也没做,而且 IsVisible="{Binding IsEditButtonShown, Source={x:Reference CurrentViewModel}}

我有一个标签:

<Label BindingContext="{Binding BModel}"
       Text="{Binding BoundDataItem.CurrentValue.Value}"
       IsVisible="{Binding IsEditButtonShown}"/>
什么也没做,而且

IsVisible="{Binding IsEditButtonShown, Source={x:Reference CurrentViewModel}}
提供了一个关于找不到ViewModel的错误(这是在使用xmlns:ViewModel=“clr namespace…”将其添加到页面顶部后发生的)

我也尝试过用另一种方法,在BModel中使用Source=x:Reference,但也不起作用


有什么想法吗?

显然我是个白痴。看来我根本不需要该项目的BindingContext。现在标签看起来像这样:

<Label Text="{Binding BModel.BoundDataItem.CurrentValue.Value}"
       IsVisible="{Binding IsEditButtonShown}"/>

而且它看起来像它应该的那样工作

有趣的是,当你开始向别人解释这些事情时,你会想到这些事情

<Label Text="{Binding BModel.BoundDataItem.CurrentValue.Value}"
       IsVisible="{Binding IsEditButtonShown}"/>