我有一个带有 Source 属性绑定到默认源的图像的数据模板(可观察的集合,它工作正常)。问题是我需要将其 IsVisible 属性绑定到其他源(在我的代码中声明的对象)但是在运行应用程序时我在控制台上得到了这个:
Binding: 'ScrollEvent' property not found on 'Xamarin.Forms.Binding', target property: 'FFImageLoading.Forms.CachedImage.IsVisible'
我的代码的相关部分:
我的页面.xaml
<DataTemplate x:Key="MapMsgSend">
...
<ffimageloading:CachedImage
Source="{Binding imageSource}"
IsVisible="{Binding Source={Binding MyPage}, Path=ScrollEvent.Visibility}">
</ffimageloading:CachedImage>
...
</DataTemplate>
MyPage.xaml.cs(相关部分)
namespace Project.XAML
{
public partial class MyPage : ContentPage
{
public MyPage(){
this.BindingContext=this;
}
public IsScrolling ScrollEvent = new IsScrolling() { ShowImage = true };
}
}
编辑
public class IsScrolling : INotifyPropertyChanged
{
private bool _ShowImage { get; set; }
public bool ShowImage
{
get { return _ShowImage; }
set
{
_ShowImage = value;
NotifyPropertyChange("ShowImage");
}
}
public event PropertyChangedEventHandler PropertyChanged;
void NotifyPropertyChange(string PropName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(PropName));
}
}
//default value
public IsScrolling ScrollEvent = new IsScrolling() { ShowImage = true };