Zee
Zee

Reputation: 642

cannot display image in xamarin forms

Im trying to build a simply app to show an image in a stack layout, here's the code

  <?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="HelloWorld.Page1">
  <StackLayout BackgroundColor="White">
    <Image Source="http://placehold.it/300x300"/>
  </StackLayout>
</ContentPage>

but for some reason its not displaying the image at all. Can any of you see something wrong here.

Thanks!!

Upvotes: 0

Views: 780

Answers (1)

Jason Short
Jason Short

Reputation: 5324

Possibly you don't have a well formed page?

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:QuickTestXAMLImage"
             x:Class="QuickTestXAMLImage.MainPage">

  <StackLayout BackgroundColor="White">
    <Image Source="http://placehold.it/300x300"/>
  </StackLayout>

</ContentPage>

Notice that I have a xmlns:local which include the local namespace of the app. It is possible you don't have a fully formed page that results in it not even loading correctly.

This works for me just fine.

Upvotes: 1

Related Questions