gpt4 book ai didi

c# - App按钮两次进入选择事件

转载 作者:太空宇宙 更新时间:2023-11-03 11:13:56 24 4
gpt4 key购买 nike

当我点击我的应用程序按钮时,它会进入选择事件处理程序两次。知道为什么吗?

前端代码:

<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png"
Text="New"
x:Name="addIconButton"
Click="addIconButton_Click"/>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>

main后台代码:

构造函数:

addIconButton = (ApplicationBarIconButton)ApplicationBar.Buttons[0];
addIconButton.Click +=new EventHandler(addIconButton_Click);

事件处理器:

private void addIconButton_Click(object sender, EventArgs e)
{
MessageBox.Show("enters addIcon Main");
Note note = new Note();
note.Modified = DateTimeOffset.Now;

if (note != null)
{
Settings.NotesList.Add(note);
//Settings.NotesList[0] = note;
}
Settings.CurrentNoteIndex = 0;
this.NavigationService.Navigate(new Uri("/DetailsPage.XAML",UriKind.Relative));

//DetailsPage mynewPage = new DetailsPage();
//this.Content = mynewPage;
}

最佳答案

Click="addIconButton_Click" //in your Front-end code

然后,

addIconButton.Click +=new EventHandler(addIconButton_Click);

你不是刚刚添加了两次点击处理程序吗?

关于c# - App按钮两次进入选择事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13214367/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com