I'm trying out embedded images. First I get constantly "MarkupExtension not found for local". This is fixed it seems. My image is still not loading.
What am I doing wrong?
Some noob questions:
What assembly should I reference on this line?
xmlns:image="clr-namespace:Images"
What is the path to my image? Is App4.scooter.png correct?
I'm so confused and frustrated by all the erros I saw the last couple days.
This is my code: imgur.com /a/3id7ntu
using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace Images{
[ContentProperty(nameof(SourceID))]
public class ImageResourceExtension : IMarkupExtension
{
public string SourceID { get; set; }
public object ProvideValue(IServiceProvider serviceProvider)
{
if (SourceID == null)
{
return null;
}
// Do your translation lookup here, using whatever method you require
var imageSource = ImageSource.FromResource(SourceID);
return imageSource;
}
}
}
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="xamarin.com/schemas/2014/forms"
xmlns:x="schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:App4"
xmlns:image="clr-namespace:Images"
x:Class="App4.MainPage">
<StackLayout>
<!-- Place new controls here -->
<Image Source="{image:ImageResource App4.scooter.png}" />
</StackLayout>
</ContentPage>