title: Change XML Background Programmatically - Xamarin.Android C#
body: <p>I'm trying to change a Button <code>background</code> property programmatically using <code>Xamarin.Android</code> C# but can't get it done.</p>
  <p>Xml file:</p>
  <pre><code>... &lt;Button
                          p1:id=&quot;@+id/BtnGo&quot;
                          p1:layout_width=&quot;wrap_content&quot;
                          p1:layout_height=&quot;30dp&quot;
                          p1:paddingHorizontal=&quot;15dp&quot;
                          p1:text=&quot;Go&quot;
                          p1:textColor=&quot;#ffffff&quot;
                          p1:textSize=&quot;15dp&quot;
                          p1:background=&quot;@drawable/togglefocus&quot;
                          p1:textAllCaps=&quot;false&quot;
                          p1:layout_gravity=&quot;center&quot; /&gt; ...
  </code></pre>
  <p>Need to change</p>
  <pre><code>p1:background=&quot;@drawable/togglefocus&quot;
  </code></pre>
  <p>To</p>
  <pre><code>p1:background=&quot;@drawable/myfocus&quot;
  </code></pre>
  <p>But on execution time / Programmatically (C#).</p>
  <p>Tried this:</p>
  <pre><code>        Btn = FindViewById&lt;Button&gt;(Resource.Id.BtnGo);
          Btn.Click += delegate           
          {                
              Btn.Background(&quot;@drawable/myfocus&quot;); //myfocus is an xml file in: Resources &gt; Drawable
          };
  </code></pre>
  <p>Any Ideas?</p>