title: Create ControlTemplate programmatically in WPF
body: <p>How can I programmatically set a button's template?</p>
  
  <pre><code>Polygon buttonPolygon = new Polygon();
  buttonPolygon.Points = buttonPointCollection;
  buttonPolygon.Stroke = Brushes.Yellow;
  buttonPolygon.StrokeThickness = 2;
  
  // create ControlTemplate based on polygon
  ControlTemplate template = new ControlTemplate();
  template.Childeren.Add(buttonPolygon); // This does not work! What's the right way?
  
  //create button based on controltemplate
  Button button = new Button();
  button.Template = template;
  </code></pre>
  
  <p>So I need a way to set my Polygon as the button's template. Suggestions?</p>
  
  <p>Thanks.</p>