2012-04-26 34 views
3

我已经添加了一个新的ApplicationBarMenu带有图标的按钮到我的wp7项目的页面。当试图运行我得到的页面时:添加新的ApplicationBarMenuItem时无法分配给属性图标

未能分配给属性 '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似乎不认识它,或别的东西是错误的。

谢谢

回答

10

问题出在事件处理程序签名。您有第二个参数RoutedEventArgs。它应该是EventArgs

Here is an explanation。不要忘记,应用栏是一个外壳对象。

+0

谢谢你,你是对的。你介意解释吗? – Michael 2012-04-26 21:29:36

+0

编辑答案。 – 2012-04-26 21:31:44

相关问题