Failed to assign to property when adding new ApplicationBarMenuItem icon

余生颓废 提交于 2019-12-10 18:34:01

问题


I've added a new ApplicationBarMenu button with icon to a page in my wp7 project. when trying to run the page i get :

Failed to assign to property 'Microsoft.Phone.Shell.ApplicationBarIconButton.Click'. [Line: 56 Position: 124]

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>

I have checked ten times that i have a method in the .xaml.cs :

private void SendReportClick(object sender, RoutedEventArgs e)

But still, VS doesnt seem to recognize it, or something else is wrong.

Thanks


回答1:


The problem is in the event handler signature. You have RoutedEventArgs as the second parameter. It should just be EventArgs.

Here is an explanation. Don't forget that the app bar is a shell object.



来源:https://stackoverflow.com/questions/10339685/failed-to-assign-to-property-when-adding-new-applicationbarmenuitem-icon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!