I need to do something only once (in my case creating an instance of a class). The closest thing I can find is putting it in the PhoneApplicationPage_Loaded event handler, or at the top of MainPage.xaml. But this doesn’t work for me because I have other pages in my app, so if I navigate from another page back to the MainPage it executes that code again.
Thanks, David
When you create a new project, you will find an
App.xaml.csfile added to your project. Here you can add code that is executed at various points in your application lifecycle. You can add code to the method thar handles theLaunchingevent:This code will be executed just once when you application launches.