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?

Subby
  • 5,370
  • 15
  • 70
  • 125

2 Answers2

3

It's because you haven't set the Text property for the backbutton.

ApplicationBarIconButton backButton = new ApplicationBarIconButton(new Uri("/Images/back.png", UriKind.Relative));
backButton.Text = "Previous"; //<< you have nextButton.Text
keyboardP
  • 68,824
  • 13
  • 156
  • 205
0

Hey the problem is your not actually setting the text for the back button, youve set nextButton.Text on both :)

Carl
  • 548
  • 1
  • 4
  • 21