an Xaml extension to get images from resources
This commit is contained in:
parent
8e477bbe9f
commit
6e33f995c1
1 changed files with 24 additions and 0 deletions
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue