WP8无效操作

本文关键字:操作 无效 WP8 | 更新日期: 2023-09-27 18:27:08

我得到一个:

An exception of type 'System.InvalidOperationException' occurred in Microsoft.Phone.ni.dll but was not handled in user code

当我这样做时:

ApplicationBarIconButton nextButton = new ApplicationBarIconButton(new Uri("/Images/next.png", UriKind.Relative));
nextButton.Text = "Next";
ApplicationBarIconButton backButton = new ApplicationBarIconButton(new Uri("/Images/back.png", UriKind.Relative));
nextButton.Text = "Previous";
ApplicationBar.Buttons.Add(nextButton);
ApplicationBar.Buttons.Add(backButton); //<---- Error when adding this

有人能看出我哪里出了大问题吗?

WP8无效操作

这是因为您没有为backbutton设置Text属性。

ApplicationBarIconButton backButton = new ApplicationBarIconButton(new Uri("/Images/back.png", UriKind.Relative));
backButton.Text = "Previous"; //<< you have nextButton.Text

嘿,问题是你实际上没有设置后退按钮的文本,你已经设置了nextButton。两者上的文本:)