سؤال

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?

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top