[英]which method is first called when a xaml page is loaded in windows phone by default?
我想知道在windows phone app中加载xaml页面时默认首先调用哪个方法,如何更改必须在加载时首先调用的方法?
To automatically perform an action on page load, use this in your page constructor:- 要在页面加载时自动执行操作,请在页面构造函数中使用此操作: -
public MainPage()
{
InitializeComponent();
Loaded += (s, e) =>
{
//write logic here
}
}
You can also set the Loaded
handler via xaml: 您还可以通过xaml设置
Loaded
处理程序:
.xaml: 的.xaml:
<Page
...
Loaded="OnPageLoaded">
.xaml.cs: .xaml.cs:
private void OnPageLoaded(object sender, RoutedEventArgs e)
{
...
}
To directly answer your question: Initialize is the event you are looking for. 直接回答您的问题:Initialize是您要查找的事件。
For more detailed information, Google is your friend: 有关更多详细信息,Google是您的朋友:
Application lifecycle - http://msdn.microsoft.com/en-us/windowsphonetrainingcourse_applicationlifetimewp7lab_topic2.aspx 应用程序生命周期 - 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 http://msdn.microsoft.com/en-us/library/ms754221.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.