添加新的 ApplicationBarMenuItem 图标时无法分配给属性 [英] Failed to assign to property when adding new ApplicationBarMenuItem icon
问题描述
我在 wp7 项目的页面上添加了一个带有图标的新 ApplicationBarMenu
按钮.尝试运行页面时,我得到:
I've added a new ApplicationBarMenu
button with icon to a page in my wp7 project. when trying to run the page i get :
无法分配给属性'Microsoft.Phone.Shell.ApplicationBarIconButton.Click'.[行:56位置:124]
Failed to assign to property 'Microsoft.Phone.Shell.ApplicationBarIconButton.Click'. [Line: 56 Position: 124]
指向我添加的新菜单项按钮(第二个,send_report_button
):
Which points to the new menu item button i have added (the second one, send_report_button
):
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBarIconButton x:Name="take_photo_button" IconUri="/Images/appbar.feature.camera.rest.png" Text="Take photo" Click="TakePhotoClick" />
<shell:ApplicationBarIconButton x:Name="send_report_button" IconUri="/Images/mail.sent.png" Text="Send report" Click="SendReportClick" />
<shell:ApplicationBarIconButton x:Name="logout_button" IconUri="/Images/appbar.logout.rest.png" Text="Logout"/>
<shell:ApplicationBar.MenuItems>
<!--<shell:ApplicationBarMenuItem x:Name="menuItem1" Text="MenuItem 1"/>
<shell:ApplicationBarMenuItem x:Name="menuItem2" Text="MenuItem 2"/>-->
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
我已经检查了十次我在 .xaml.cs
中有一个方法:
I have checked ten times that i have a method in the .xaml.cs
:
private void SendReportClick(object sender, RoutedEventArgs e)
但是,VS 似乎还是没有识别出来,或者其他地方出了问题.
But still, VS doesnt seem to recognize it, or something else is wrong.
谢谢
推荐答案
问题出在事件处理程序签名中.您将 RoutedEventArgs
作为第二个参数.它应该只是 EventArgs
.
The problem is in the event handler signature. You have RoutedEventArgs
as the second parameter. It should just be EventArgs
.
这里有说明.不要忘记 app bar 是一个 shell 对象.
Here is an explanation. Don't forget that the app bar is a shell object.
这篇关于添加新的 ApplicationBarMenuItem 图标时无法分配给属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!