an Xaml extension to get images from resources
This commit is contained in:
24
BookAStar/BookAStar/Extensions/ImageResourceExtension.cs
Normal file
24
BookAStar/BookAStar/Extensions/ImageResourceExtension.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Xaml;
|
||||
|
||||
namespace BookAStar.Extensions
|
||||
{
|
||||
[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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user