【问题标题】:Calling GetImageAsPngAsync of FFImageLoading from ViewModel class?从 ViewModel 类调用 FFImageLoading 的 GetImageAsPngAsync?
【发布时间】:2017-12-19 20:45:51
【问题描述】:

对 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}">

我的 ViewModel 类:

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 from the XAML file to ViewModel file。

任何帮助将不胜感激。

【问题讨论】:

    标签: xamarin.forms ffimageloading


    【解决方案1】:
    var stream = await ImageService.Instance.LoadUrl(Photo1).AsPNGStreamAsync();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-19
      • 2013-06-19
      • 1970-01-01
      相关资源
      最近更新 更多