JackxBlack
JackxBlack

Reputation: 3

Xamarin - Image from URI isn't rendered despite being seemingly downloaded

let me start by saying sorry if this is already answered somewhere, I searched for very long time and couldn't find an answer that works.

So as per title, I have a very simple app with literally one page that should display one image from URI and that's it. For some reason the image doesn't show up neither when deploying on a physical device nor on emulator. Image works fine, it's just a random image from web (http://thumbs.dreamstime.com/z/watercolor-autumn-forest-landscape-sunset-hand-drawn-painting-fantasy-art-nature-beautiful-background-gouache-153834924.jpg). I've attached ActivityIndicator that stops spinning after a second, so I would assume that the image is loaded, so it's not an issue with app not connecting to the web and simply image rendering...

I've tried setting Android Options -> Advanced -> HttpClient implementation to Managed and SSL/TLS implementation to Native TLS 1.2+, as well as Android Manifest -> Required Permissions -> Internet. Neither helped. I tried using http:// and https://, no results neither. I'm very confused at the moment.

Here's my App.xaml.cs:

using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using App1.Services;
using App1.Views;

namespace App1
{
    public partial class App : Application
    {
        public App()
        {
            InitializeComponent();

            DependencyService.Register<MockDataStore>();
            MainPage = new ImagePage();
        }
    }
}

Here's ImagePage.xaml.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace App1
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class ImagePage : ContentPage
    {
        public ImagePage()
        {
            InitializeComponent();

            var imageSource = new UriImageSource { Uri = new Uri("http://thumbs.dreamstime.com/z/watercolor-autumn-forest-landscape-sunset-hand-drawn-painting-fantasy-art-nature-beautiful-background-gouache-153834924.jpg") };
            imageSource.CachingEnabled = false;

            image.Source = imageSource;
        }
    }
}

and here's xaml for this 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:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             x:Class="App1.ImagePage">
    <AbsoluteLayout>
        <ActivityIndicator IsRunning="{Binding Source={x:Reference image}, Path=IsLoading}" AbsoluteLayout.LayoutBounds="0.5, 0.5, 100, 100" AbsoluteLayout.LayoutFlags="PositionProportional"/>
        <Image IsVisible="True" x:Name="image"/>
    </AbsoluteLayout>
</ContentPage>

I would greatly appreciate any help :). As I said, this is extremely simple and I have no clue why this doesn't work at this point.

Upvotes: 0

Views: 57

Answers (1)

Leo Zhu
Leo Zhu

Reputation: 15021

What's your Xamarin.Forms version ?There is an issue reported in Xamarin.forms version 4.2.0.778463 early and that it has been fixed in the Xamarin.forms version 4.2.0.848062.

So you could try to update your Xamarin.forms version

Upvotes: 2

Related Questions