Xamarin does not allow you to use an image from external storage or Url as background image of ContentPage.
so instead of setting a BackgroundImage ="image_name_in_resources" inside the root tag of page ( ContentPage ) , put it in an Image tag neighboring you inside code , both inside an AbsoluteLayout
here's a snippet of my Code
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
.....
.....>
<AbsoluteLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<Image x:Name="imageBG" AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0, 0, 1, 1" Aspect="AspectFill" Source="myimage.jpg" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"/>
<StackLayout AbsoluteLayout.LayoutBounds="0, 0, 1, 1" AbsoluteLayout.LayoutFlags="All" >
....
</StackLayout>
</AbsoluteLayout>
to change the source prof CS code here's a little snippet i worked with
string serverAdress = Constants.HTTP_PRE + Constants.SERVER_IP;
Logo.Source = new UriImageSource
{
Uri = new Uri(serverAdress + Constants.HEADER_IMAGE),
CachingEnabled = true
};
For more controle over whether the server response is valid ...
try
{
string url = Constants.HTTP_PRE + DependencyService.Get<IStoredData>().GetData(Constants.SHARED_PREF_ADDRESS);
url += Constants.HEADER_IMAGE;
HttpWebRequest wrq = (HttpWebRequest)WebRequest.Create(url);
//You should be getting only the response header
wrq.Method = "HEAD";
if ( ( (HttpWebResponse)wrq.GetResponse() ).ContentLength > 0) // if filePath is correct - serverIP is set
{
Uri uri = new Uri(url);
UriImageSource uriImageSource = new UriImageSource { Uri = uri, CachingEnabled = true };
Logo.Source = uriImageSource;
}
}catch (Exception e) { System.Console.WriteLine(e.StackTrace); }