IsVisible对象的默认值始终为true.这与Binding无关.您可以使用以下内容覆盖代码隐藏文件中的此值:
HeightRequest="20" HorizontalOptions="End" VerticalOptions="End"
IsVisible="{Binding PropertyNameOfYourModel}" />
// Somewhere in the constructor
this.myImage.IsVisible = false;
// Here the binding is set at a later time
this.BindingContext = yourModelObject;
this.myImage.SetBinding(Image.IsVisibleProperty,"PropertyNameOfYourModel");
另一种解决方案可能是DataTrigger,但我还没有测试过:
Source
如果您可以等待Xamarin.Forms 3.2.0,则可以直接在Xamarin Xaml中使用FallbackValue和TargetNullValue选项.