Created
February 8, 2021 01:56
-
-
Save SnowyPainter/60fac19ce4581df6d8e336a6c339b93a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Reflection; | |
using Xamarin.Forms; | |
using Xamarin.Forms.Xaml; | |
namespace HeVibrates | |
{ | |
[ContentProperty (nameof(Source))] | |
class ImageResourceExtension:IMarkupExtension | |
{ | |
public string Source { get; set; } | |
public object ProvideValue(IServiceProvider serviceProvider) | |
{ | |
if (Source == null) return null; | |
var imgSource = ImageSource.FromResource(Source, typeof(ImageResourceExtension).GetTypeInfo().Assembly); | |
return imgSource; | |
} | |
} | |
} | |
//xmlns:local ="clr-namespace:PROJECTNAME" | |
//<Image Source="{local:ImageResource Source=PROJCETNAME.IMAGEPATH}"/> | |
//IMAGEPATH = Folder.Image.png |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment