title: Xamarin Forms - how to add background image to a content page
body: <p>I am trying to assign Background Image to my content designed in <code>xaml</code>. I have tried different approaches but it is not showing me background image. Here is the code I have written: </p>
  
  <p><strong>Content Page:</strong> </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
               xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
               x:Class="Demo.Welcome"
               BackgroundImage="bg1.jpg"&gt;
  
    &lt;ContentPage.Content&gt;
      &lt;StackLayout  HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" Spacing="25" Padding="0" x:Name="stackLayoutMain"&gt;
        &lt;Label FontSize="40" Text="WelCome Page" HorizontalOptions="Start" VerticalOptions="StartAndExpand"&gt;&lt;/Label&gt;
        &lt;Entry Placeholder="Activation Key" WidthRequest="200" FontSize="15" HorizontalOptions="Center" VerticalOptions="StartAndExpand" TextChanged="entryActivationTextChanged" x:Name="entryActivationKey" Keyboard="Numeric" HorizontalTextAlignment="Center"&gt;&lt;/Entry&gt;
        &lt;Button
          x:Name="buttonActivate"
          BackgroundColor="#fff"
          Text="Activate"
          WidthRequest="100"
          HeightRequest="50"
          HorizontalOptions="Center"
          VerticalOptions="StartAndExpand"
          TextColor="#377CC1"
          IsVisible="False"
          Clicked="buttonActivateClicked" &gt;
        &lt;/Button&gt;
      &lt;/StackLayout&gt;
    &lt;/ContentPage.Content&gt;
  &lt;/ContentPage&gt;
  </code></pre>
  
  <p><code>bg1.jpg</code> is image in my portable project which i want to set as a background and I have set property </p>
  
  <ul>
  <li><code>Build Action = "Content"</code> and  </li>
  <li><code>Copy to Output Directory = "Copy Always"</code></li>
  </ul>
  
  <p>And Below is the directory structure of my project. </p>
  
  <p><a href="https://i.stack.imgur.com/cOdtF.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cOdtF.png" alt="Directory Structure"></a></p>