【发布时间】:2017-06-02 03:45:51
【问题描述】:
当我更改它们的 ImageSource 时,我正在尝试更新/重新绘制页面中的图像 - 这将帮助我让它们异步重新加载。
我认为为 imageSource 绑定到图像的可绑定属性是一个开始,但它并没有更新图像。我尝试了很多方法,包括带有 OnPropertyChanged 事件的 viewModel 方法,但我认为我不太了解这一点。
此绑定也必须在代码中完成,这就是应用程序的编写方式(最小 xaml)。
到目前为止,我的一般做法是:
可绑定属性
public static readonly BindableProperty ImageFileProperty =
BindableProperty.Create("ImageProperty", typeof(string),
typeof(CustomImageClass));
public string ImageProperty
{
get
{
return (string)GetValue(ImageFileProperty);
}
set
{
SetValue(ImageFileProperty, value);
}
}
CustomImageClass 构造函数内部:
this.SetBinding(ImageFileProperty, "ImageProperty");
从这里我希望在更新 ImageSource 并更改图像时更改图像。我希望这足够具体,我认为绑定到 xaml 的所有不同示例都让我感到困惑,因为我需要在代码中执行它。
【问题讨论】:
标签: c# xamarin.forms bindable