我添加了一个新的ApplicationBarMenu
带有图标的按钮到我的 wp7 项目中的页面。当尝试运行页面时我得到:
无法分配给属性
'Microsoft.Phone.Shell.ApplicationBarIconButton.Click'。 [线路:56
位置:124]
它指向我添加的新菜单项按钮(第二个,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
:
private void SendReportClick(object sender, RoutedEventArgs e)
但VS似乎还是没有识别出它,或者是其他地方出了问题。
Thanks
问题出在事件处理程序签名中。你有RoutedEventArgs
作为第二个参数。应该只是EventArgs
.
这是一个解释 https://stackoverflow.com/a/1428775/303696。不要忘记应用栏是一个 shell 对象。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)