Hello,
I tried to add embedded image in my shared project.
I created Shared project for Android & IOS.
Added images in shared project.
For rendering, in XAML file :
in same namespace **AllControl **I implemented interface IMarkupExtension.
[Preserve(AllMembers = true)]
[ContentProperty(nameof(Source))]
public class ImageResourceExtension : IMarkupExtension
{
public string Source { get; set; }
public object ProvideValue(IServiceProvider serviceProvider)
{
if (Source == null)
{
return null;
}
// Do your translation lookup here, using whatever method you require, typeof(ImageResourceExtension).GetTypeInfo().Assembly
Console.WriteLine(typeof(ImageResourceExtension).GetTypeInfo().Assembly);
var imageSource = ImageSource.FromFile(Source);
return imageSource;
}
}
Set image property Build Action as Embedded resource
Same code is working fine for PCL.
Please give suggestion for Shared project.
Thank you