Hi, I am using markup extension developed by ( @NMackay ) to display images on android and uwp platform.
Everything works fine in xaml, however now I need to display icon in toolbar in UWP app (which is working fine in Android).
I need to know how can I refer this extension in my code C# code.
var toolbarItem = new ToolbarItem
{
Text = "ABC",
Order = ToolbarItemOrder.Primary,
Icon = "search.png", **//How to refer extension to display this icon**
Command = viewModel.MysearchCommand
};
I am copy & pasting the extension here, since right now I cant post the links in this forum.
public class PlatformImageExtension : IMarkupExtension<string>
{
public string SourceImage { get; set; }
public string ProvideValue(IServiceProvider serviceProvider)
{
if (SourceImage == null)
return null;
string imagePath;
switch (Device.RuntimePlatform)
{
case Device.Android:
imagePath = SourceImage;
break;
case Device.iOS:
imagePath = SourceImage + ".png";
break;
case Device.WinPhone:
imagePath = "Images/" + SourceImage + ".png";
break;
case Device.Windows:
imagePath = "Images/" + SourceImage + ".png";
break;
default:
throw new ArgumentOutOfRangeException();
}
return imagePath;
}
object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider)
{
return ProvideValue(serviceProvider);
}
}