1

I am getting a:

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

When I do:

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

Can anyone see where I am going horribly wrong?

4

2 回答 2

3

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

ApplicationBarIconButton backButton = new ApplicationBarIconButton(new Uri("/Images/back.png", UriKind.Relative));
backButton.Text = "Previous"; //<< you have nextButton.Text
于 2013-08-11T13:36:13.083 回答
0

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

于 2013-08-11T13:43:40.880 回答