【问题标题】:WP8 InvalidOperationWP8 无效操作
【发布时间】:2013-08-11 13:08:55
【问题描述】:

我得到一个:

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

谁能看出我哪里出了大错?

【问题讨论】:

标签: c# windows-phone-8 invalidoperationexception


【解决方案1】:

这是因为您没有为后退按钮设置Text 属性。

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

【讨论】:

  • 呃!非常感谢。
【解决方案2】:

嘿,问题是你实际上并没有为后退按钮设置文本,你在两者上都设置了 nextButton.Text :)

【讨论】:

  • 啊,该死的打败我了
猜你喜欢
  • 1970-01-01
  • 2012-08-08
  • 1970-01-01
  • 1970-01-01
  • 2019-11-26
  • 2010-10-02
  • 2016-06-08
  • 1970-01-01
相关资源
最近更新 更多