title: Customizing Xamarin.Forms layouts
body: <p>I'm building an Android and iOS app using Xamarin Forms. </p>
  
  <p>What I'm simply trying to do is set a background drawable on my Android app for my <code>ListView</code> items. The root view of my <code>ListView</code> items are <code>StackLayout</code>'s:</p>
  
  <pre><code>var listView = new ListView
  {
      ItemsSource = items,
      ItemTemplate = new DataTemplate(() =&gt;
      {
          return new ViewCell
          {
              View = new StackLayout(...)
          };
      }
  };
  </code></pre>
  
  <p>I know I can access the native element by using a custom renderer:</p>
  
  <pre><code>public class MyEntryRenderer : EntryRenderer
  {
      protected override void OnElementChanged(ElementChangedEventArgs&lt;Entry&gt; e)
      {
          base.OnElementChanged(e);
  
          if (e.OldElement == null) {
              var nativeEditText = (EditText)Control;
              ...
          }
      }
  }
  </code></pre>
  
  <p>But I'm not sure how this would work for a <code>StackLayout</code> (or any other layout for that matter).</p>
  
  <p>I first extended <code>StackLayout</code>:</p>
  
  <pre><code>public class ListViewItem : StackLayout
  {
  }
  </code></pre>
  
  <p>And I read somewhere that layouts use the <code>VisualElementRenderer</code>, so I tried the following:</p>
  
  <pre><code>public class ListViewItemRenderer : VisualElementRenderer&lt;StackLayout&gt;
  {
      protected override void OnElementChanged(ElementChangedEventArgs&lt;StackLayout&gt; e)
      {
          base.OnElementChanged(e);
  
          // any way to access the native element?
      }
  }
  </code></pre>
  
  <p>But <code>VisualElementRenderer</code> does not seem to give me access to the native element. </p>
  
  <p>So is there any way I can access the native elements of Layout elements? Or maybe there is a different way to simply set a background drawable on layouts within my Android app?</p>