Hi all,
Is it possible to add "embedded" images if the solution has the shared project?
What I do is:
- I add an image (logohome.jpg) to the Shared project with build action = "Embed resource"
- I try to get it from the page class via ImageSource.FromResource (namespace.nameofimage.extension)
The class is this:
namespace testImage {
public class HomePage:ContentPage
{
public HomePage ()
{
StackLayout MainStackLayout = new StackLayout {
VerticalOptions = LayoutOptions.StartAndExpand,
HorizontalOptions = LayoutOptions.CenterAndExpand,
Padding = new Thickness(0, 20, 0, 0)
};
MainStackLayout.Orientation = StackOrientation.Vertical;
Image MyImage= new Image { Aspect=Aspect.AspectFit};
MyImage.Source = ImageSource.FromResource ("testImage.logohome.jpg");
Label SearchLabel = new Label ();
SearchLabel.Text = "Search";
MainStackLayout.Children.Add (MyImage);
MainStackLayout.Children.Add (SearchLabel);
Content = MainStackLayout;
}
}
}