【发布时间】:2019-01-20 05:30:03
【问题描述】:
我有一个项目,它的资源文件夹中包含一堆图像。 但是现在我想通过将图像下载到存储中然后使用它来使用它们。但要做到这一点,我必须将转换器应用于所有图像。 是否可以将转换器隐式应用于所有图像。或者任何其他适合这里的方法?
public class ImageFileToImageSourceConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is string name)) return null;
return ImageSource.FromFile(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), name));
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
【问题讨论】:
标签: c# visual-studio xaml xamarin xamarin.forms