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

Shared Images In Shared Project

$
0
0

Hi all,
I'm using the new Xamarin.forms and I'm building my view but I want to add an image to it.

I want to store all of my images in the same shared library, so I've created a folder called "Images" within my SharedProject and put my image in there (large.png).

Then within my method that builds the page, I've got the below code but it doesn't seem to add the image - Not even a place holder for the image.

Can anyone advise what I'm doing wrong?

        Image logo = new Image ();
        logo.Source = ImageSource.FromFile ("Images/large.png");

        Button btnLoginButton = new Button ();
        btnLoginButton.Text = "Log In";
        btnLoginButton.Clicked += (sender, e) => {
            ShowMessageBox ("Logging in...", "Message", context);
        };

        var layout = new StackLayout
        {
            VerticalOptions = LayoutOptions.FillAndExpand,
            Children = { 
                logo,
                new Entry { Placeholder = "Username" },
                new Entry { Placeholder = "Password", IsPassword = true },
                btnLoginButton
            }
        };

        return new ContentPage
        {
            Content = layout
        };      

Viewing all articles
Browse latest Browse all 58056

Trending Articles