public MainPage()
{
InitializeComponent();
ApplicationBar = new ApplicationBar();
ApplicationBar.Opacity = 1.0;
ApplicationBar.IsVisible = true;
ApplicationBar.IsMenuEnabled = true;
ApplicationBar.BackgroundColor = System.Windows.Media.Colors.Transparent;
ApplicationBarIconButton add = new ApplicationBarIconButton();
add.IconUri = new Uri("Icons/appbar.add.rest.png", UriKind.Relative);
add.Text = "add a friend";
ApplicationBar.Buttons.Add(add);
add.Click += new EventHandler(add_Click); //ERROR
ApplicationBarIconButton list = new ApplicationBarIconButton();
list.IconUri = new Uri("icons/appbar.folder.rest.png",UriKind.Relative);
list.Text = "List";
ApplicationBar.Buttons.Add(list);
ApplicationBarIconButton about = new ApplicationBarIconButton();
about.IconUri = new Uri("icons/appbar.questionmark.rest.png",UriKind.Relative);
about.Text = "about";
ApplicationBar.Buttons.Add(about);
}
答案 0 :(得分:5)
您是否在课程的任何位置定义了一个名为add_Click的方法?它需要具有以下签名:
void add_Click(object sender, EventArgs e)
{
// Put code to handle the click event in here
}
答案 1 :(得分:2)
您需要使用实际的add_Click方法连接add_Click事件。 我认为你在代码中缺少add_Click实现。