某些时候来自Xamarin.Forms资源的图片不显示并显示为黑色矩形。
无论如何都要阻止它吗?
<Image Source="{ex:ImageResource MyProjects.Images.Data.png}"
Aspect="AspectFit"
AbsoluteLayout.LayoutBounds="0.15,0.15,0.7,0.7"
AbsoluteLayout.LayoutFlags="All" >
</Image>
[ContentProperty ("Source")]
public class ImageResourceExtension : IMarkupExtension
{
public string Source { get; set; }
public object ProvideValue (IServiceProvider serviceProvider)
{
if (Source == null)
{
return null;
}
var imageSource = ImageSource.FromResource(Source);
return imageSource;
}
}