添加新的应用程序栏菜单项图标时无法分配给属性



我在 wp7 项目中的页面中添加了一个带有图标的新ApplicationBarMenu按钮。 尝试运行页面时,我得到:

无法分配给媒体资源 '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似乎没有意识到这一点,或者其他问题。

谢谢

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

这是一个解释。不要忘记应用栏是一个外壳对象。

最新更新