Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Can you use embedded images in shared project?

$
0
0

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;
        }
    }
}

Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>