在Windows Phone SDK 7.1中启动应用程序的调用方法

时间:2012-11-07 23:01:17

标签: c# visual-studio-2010 windows-phone-7

当应用程序启动时,我需要调用一个通常由mainpage.xaml的按钮触发的方法。 我是否需要使用app.xaml的Application_Launching方法?如果是,怎么样?

由于

1 个答案:

答案 0 :(得分:0)

您的目标应该是尽快显示MainPage.xaml。

而不是实际调用该方法,您应该只设置一个布尔值,指示您应该调用它,然后调用MainPage.xaml.cs中的方法(或者您的项目是否已构建)

App.xaml.cs:

public static bool IsInitialLaunch = true;

MainPage.xaml.cs中

加载事件:

if (App.IsInitialLaunch){
   SomeMethod();
   App.IsInitialLaunch = false;
}