2013-12-16 2 views
1

브라우저에 책갈피 기능을 추가하려고하지만 작성한 단추를 도구 모음에 추가하는 방법을 알 수 없습니다. 내 도구 모음에 만든 버튼을 추가하려고프로그래밍 방식으로 wpf의 도구 모음에 단추 추가

<ToolBar x:Name="Bookbar" HorizontalAlignment="Left" VerticalAlignment="Top" Width="799" Height="36"> 

     </ToolBar> 

그리고 C# 코드 :

내 XAML에 정의 도구 모음

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); 

    } 

내가

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?) 
을 잡 해요

줄에 'Bookbar.Children.Add (book1);'

내가 뭘 잘못하고 있니?

+0

해야하지 BookBar.Children.Add()? – franssu

+0

아, 죄송합니다. 메인 포스트에 추가했습니다. – manske

답변

4

그것의 당신이받는 어떤 오류 BookBar.Items.Add

+0

그것은 매력처럼 작동합니다! 고맙습니다! – manske

관련 문제