对 Xamarin 表单使用https://github.com/luberda-molinet/FFImageLoading
我的 XAML:
<forms:CachedImage
CacheType="All"
RetryDelay="1000"
DownsampleHeight="150"
RetryCount="5"
CacheDuration="1"
BackgroundColor="WhiteSmoke"
BitmapOptimizations="True"
SuccessCommand="{Binding CcCommand}"
Source = "{Binding Photo1}">
我的视图模型类:
class AboutMeViewModel : INotifyPropertyChanged
{
public ICommand CcCommand { get; set; }
public AboutMeViewModel()
{
CcCommand = new Command<CachedImageEvents.SuccessEventArgs>(ffFinishLoading);
}
void ffFinishLoading(CachedImageEvents.SuccessEventArgs ea)
{
// Here I would like to call 'GetImageAsPngAsync'
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
在 ffFinishLoading 我想调用 GetImageAsPngAsync 但我找不到在 ViewModel 类中执行此操作的方法,因为我没有参考表单的选项:CachedImage 从 XAML 文件到 ViewModel 文件。
任何帮助都感激不尽。