开发者

Why is the reason for this error?- The name 'add_Click' does not exist in the current context

开发者 https://www.devze.com 2023-04-04 03:16 出处:网络
public MainPage() { InitializeComponent(); ApplicationBar = new ApplicationBar(); ApplicationBar.Opacity = 1.0;
     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);
开发者_如何学Python
        ApplicationBarIconButton about = new ApplicationBarIconButton();
        about.IconUri = new Uri("icons/appbar.questionmark.rest.png",UriKind.Relative);
        about.Text = "about";
        ApplicationBar.Buttons.Add(about);

}


Have you defined a method called add_Click anywhere in the class? It needs to have the following signature:

void add_Click(object sender, EventArgs e)
{
    // Put code to handle the click event in here
}


You need to wire your add_Click event with the actual add_Click method. I think you are missing add_Click implementation in your code.

0

精彩评论

暂无评论...
验证码 换一张
取 消