Reputation: 151
I want to know which method is first called by default when a xaml page is loaded in windows phone app and how can I change the method which has to be called first on load?
Upvotes: 6
Views: 9882
Reputation: 4081
You can also set the Loaded
handler via xaml:
.xaml:
<Page
...
Loaded="OnPageLoaded">
.xaml.cs:
private void OnPageLoaded(object sender, RoutedEventArgs e)
{
...
}
Upvotes: 3
Reputation: 2994
To automatically perform an action on page load, use this in your page constructor:-
public MainPage()
{
InitializeComponent();
Loaded += (s, e) =>
{
//write logic here
}
}
Upvotes: 12
Reputation: 1999
To directly answer your question: Initialize is the event you are looking for.
For more detailed information, Google is your friend:
Application lifecycle - http://msdn.microsoft.com/en-us/windowsphonetrainingcourse_applicationlifetimewp7lab_topic2.aspx
Controls and other objects should follow the standard event lifecycle:
http://msdn.microsoft.com/en-us/library/ms754221.aspx
Upvotes: -2