从 ViewModel class 调用 FFImageLoading 的 GetImageAsPngAsync?
Calling GetImageAsPngAsync of FFImageLoading from ViewModel class?
将 https://github.com/luberda-molinet/FFImageLoading 用于 Xamarin Forms
我的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:
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 class 中找到执行此操作的方法,因为我无法从 XAML 中选择参考 forms:CachedImage文件到 ViewModel 文件。
任何帮助将不胜感激。
var stream = await ImageService.Instance.LoadUrl(Photo1).AsPNGStreamAsync();
将 https://github.com/luberda-molinet/FFImageLoading 用于 Xamarin Forms
我的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:
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 class 中找到执行此操作的方法,因为我无法从 XAML 中选择参考 forms:CachedImage文件到 ViewModel 文件。
任何帮助将不胜感激。
var stream = await ImageService.Instance.LoadUrl(Photo1).AsPNGStreamAsync();