title: How to set the CornerRadius of a button programmatically [WPF/VB]?
body: <p>I know <a href="https://stackoverflow.com/questions/6745663/how-to-create-make-rounded-corner-buttons-in-wpf">how to set the corner radius</a> of a button in XAML.</p>
  <p>However, I need to set the corner radius of buttons that are created programmatically (dynamic buttons), during runtime. Here's a code example:</p>
  <pre><code>    Dim pt As Thickness
  
      Dim mySolidColorBrush As SolidColorBrush = New SolidColorBrush()
      mySolidColorBrush = CType((New BrushConverter().ConvertFrom(&quot;#005EB8&quot;)), SolidColorBrush)
  
      pt.Top = 95
      
      If howMany &gt; 0 Then 
          For i = 0 To howMany - 1
              Buttons(i) = New Button With {
                  .Tag = i,
                  .Margin = New Thickness(5, 5, 5, 0),
                  .Width = 120,
                  .Height = 60,
                  .Foreground = New SolidColorBrush(Colors.White),
                  .Background = mySolidColorBrush,
                  .VerticalAlignment = VerticalAlignment.Top,
                  .HorizontalAlignment = HorizontalAlignment.Left,
                  .FontSize = 16,
                  .Content = btnName(i)
                  }
              AddHandler Buttons(i).Click, AddressOf ButtonClickDyna
              PNL_Main.Children.Add(Buttons(i))
              pt.Top += 45
          Next
      End If
  </code></pre>
  <p>I was not able to find such information on the internet and have been going through the properties of a button one by one, sadly with no success.</p>
  <p>Any help will be much appreciated as I am still a newbie.</p>