title: Add button to toolbar in wpf programmatically
body: <p>I'm trying to add a bookmark function to my browser but I can't figure out how to add my created button to the toolbar.</p>
  
  <p>My toolbar defined in XAML:</p>
  
  <pre><code>&lt;ToolBar x:Name="Bookbar" HorizontalAlignment="Left" VerticalAlignment="Top" Width="799" Height="36"&gt;
  
          &lt;/ToolBar&gt;
  </code></pre>
  
  <p>And the c# code where I try to add the created button to my toolbar:</p>
  
  <pre><code>private void Bookmark_Click(object sender, RoutedEventArgs e) //add bookmark
      {
          if (Urlbox.Text.Contains("http://") == false)
          {
              bookmarks = Microsoft.VisualBasic.Interaction.InputBox("Please insert your new bookmark", "New Bookmark", "http://" + Urlbox.Text);
  
          }
          else
          {
              bookmarks = Microsoft.VisualBasic.Interaction.InputBox("Please insert your new bookmark", "New Bookmark", Urlbox.Text);
          }
  
  
  
          Button book1 = new Button();
          book1.Content = "Test";
          book1.Click += Button_Click;
          Bookbar.Children.Add(book1);
  
      }
  </code></pre>
  
  <p>I'm recieving</p>
  
  <pre><code>Error   1   'System.Windows.Controls.ToolBar' does not contain a definition for 'Children' and no extension method 'Children' accepting a first argument of type 'System.Windows.Controls.ToolBar' could be found (are you missing a using directive or an assembly reference?)
  </code></pre>
  
  <p>on the line 'Bookbar.Children.Add(book1);'</p>
  
  <p>What am I doing wrong?</p>