【发布时间】:2019-01-24 15:44:17
【问题描述】:
我有一个标签:
<Label BindingContext="{Binding BModel}"
Text="{Binding BoundDataItem.CurrentValue.Value}"
IsVisible="{Binding IsEditButtonShown}"/>
如果没有 Binding 上下文,IsVisible 属性就可以正常工作,但是现在我需要为特定的数据提供绑定上下文,但我仍然需要 IsVisible 属性才能工作。 IsEditButtonShown 是我的视图模型上的一个属性。
我试过了:
IsVisible="{Binding IsEditButtonShown, Source={x:Reference CurrentPagename}}
什么也没做,并且
IsVisible="{Binding IsEditButtonShown, Source={x:Reference CurrentViewModel}}
出现关于无法找到 ViewModel 的错误(这是在使用 xmlns:viewmodel="clr-namespace..." 将其添加到页面顶部之后)
我也尝试过另一种方式,将 Source=x:Reference 与 BModel 一起使用,但这也不起作用。
有什么想法吗?
【问题讨论】: