title: Grid.ColumnSpan on C# by programability
body: <p>How could I set the Grid.ColumnSpan on C# by programability?</p>
  <p>This is my code:</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;Grid&gt;
      &lt;Grid.ColumnDefinitions&gt;
          &lt;!--B1 --&gt;
          &lt;ColumnDefinition/&gt;
          &lt;!--B2 --&gt;
          &lt;ColumnDefinition/&gt;
          &lt;!--B3 --&gt;
          &lt;ColumnDefinition/&gt;
          &lt;!--B4 --&gt;
          &lt;ColumnDefinition/&gt;
      &lt;/Grid.ColumnDefinitions&gt;
      &lt;!--B1 --&gt;
      &lt;dxe:SimpleButton x:Name=&quot;btn_1&quot; Grid.Column=&quot;0&quot;/&gt;
      &lt;!--B2 --&gt;
      &lt;dxe:SimpleButton x:Name=&quot;btn_2&quot; Grid.Column=&quot;1&quot;/&gt;
      &lt;!--B3 --&gt;
      &lt;dxe:SimpleButton x:Name=&quot;btn_3&quot; Grid.Column=&quot;2&quot;/&gt;
      &lt;!--B4 --&gt;
      &lt;dxe:SimpleButton x:Name=&quot;btn_4&quot; Grid.Column=&quot;3&quot;/&gt;
  &lt;/Grid&gt;
  </code></pre>
  <p>I would like to set <code>Grid.ColumnSpan = 2</code> on my secound column if a conditional is true.</p>
  <pre><code>if(conditional){
      btn_2.Grid.ColumnSpan = 2;
  }
  </code></pre>
  <p>SOLUTION:</p>
  <pre><code>if(conditional){
      btn_2.SetValue(Grid.ColumnSpanProperty, 2);
  }
  </code></pre>