在Windows Phone 8中,當我按下開始按鈕時,我應該得到Application_Deactivated
和Application_Closing
事件。但是當我在這些事件中設置斷點時,斷點不會命中。爲什麼Application_Closing
和Application_Deactivated
沒有被調用?爲什麼應用程序沒有收到應用程序關閉事件?
Occurs when an application stops being the foreground application.
的App.xaml
<Application
x:Class="ContineousLocationTracking.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone">
<!--Application Resources-->
<Application.Resources>
<local:LocalizedStrings xmlns:local="clr-namespace:ContineousLocationTracking" x:Key="LocalizedStrings"/>
</Application.Resources>
<Application.ApplicationLifetimeObjects>
<!--Required object that handles lifetime events for the application-->
<shell:PhoneApplicationService
Launching="Application_Launching" Closing="Application_Closing"
Activated="Application_Activated" Deactivated="Application_Deactivated"
RunningInBackground="PhoneApplicationService_RunningInBackground"
/>
</Application.ApplicationLifetimeObjects>
</Application>
這些方法中是否有任何代碼?因爲如果它們是空的,編譯器可以刪除它們。 – xmashallax
你是如何設置這些事件的? – CathalMF
@xmashallax不,我在事件中有代碼 –