天天看點

Windows Phone 7 Tips (3)

1. Windows Phone 7是一個多任務的作業系統,但是隻允許唯一一個第三方應用程式在前台運作

2. 啟動器和選擇器為應用程式提供間接通路手機内置功能的方法。

一些内置的啟動器:EmailComposeTask、MarketplaceDetailTask、MarketplaceHubTask、MarketplaceReviewTask、MarketplaceSearchTask、MediaPlayerLauncher、PhoneCallTask、SearchTask、SmsComposeTask、WebBrowserTask。

一些内置的選擇器:CameraCaptureTask、EmailAddressChooserTask、PhoneNumberChooserTask、PhotoChooserTask、SaveEmailAddressTask、SavePhoneNumberTask。

3. 當啟動啟動器或者選擇器時,應用程式會進入Deactivate狀态(注意不一定會Tombstone)當Task隻寫完畢後,原有應用程式會被重新激活,應用程式會調用Activated事件,頁面會觸發OnNavigationTo事件

4. 如果Windows Phone 7中的應用程式被Tombstone了,那麼再次打開應用程式時,會生成一個新的執行個體,即會調用App和頁面的構造函數,是以我們的邏輯代碼不要放到構造函數中,而是在Application_Activated、OnNavigationTo事件中寫恢複狀态的代碼。

5. 判斷Windows Phone 7中的網絡是否可用

if (Microsoft.Phone.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) { //網絡可用

6.Windows Phone 7中的導航類:PhoneApplicationFrame 和 PhoneApplicationPage . Windows Phone 7中的

<nav:UriMapper x:Key="nav">   

<nav:UriMapping Uri="Home" MappedUri="/Pages/Views/Default.xaml"/>   

<nav:UriMapping Uri="About-Us" MappedUri="/Pages/Views/Misc/About.xaml"/>   

<nav:UriMapping Uri="Page/{number}" MappedUri="/Pages/Views/Books/Page{number}.xaml"/>   

<nav:UriMapping Uri="Customers/{id}" MappedUri="/Pages/Views/Data/Page.xaml?action=getCustomer&id={id}"/>   

<nav:UriMapping Uri="Products/{id}" MappedUri="/Pages/Views/Data/Page.xaml?action=getProduct&id={id}"/>   

<nav:UriMapping Uri="Orders/{type}&{id}&{date}" MappedUri="/Pages/Views/Data/Page.xaml?action={type}&orderId={id}&orderDate={number}"/>   

</nav:UriMapper> 

7.WMAppManifest.xml :一個包含了應用程式特定資料的中繼資料檔案,包括标題,圖示位置,功能等等。

8. 頁面導航方案

(1)在XAML代碼直接寫XAML檔案位址,如<HyperlinkButton Content="Pasta" NavigateUri="/Pasta.xaml" Height="30" HorizontalAlignment="Left"   

Margin="10,10,0,0" Name="hyperlinkButton1" VerticalAlignment="Top" Width="200" />  

(2)在XAML代碼中利用别名進行導航,需要在App.xaml中配置  

(3)利用事件處理,如 NavigationService.Navigate(new Uri("/Pasta.xaml", UriKind.Relative)); 

照例,提供離線檔案下載下傳

<a target="_blank" href="http://alexis.blog.51cto.com/attachment/201105/2621421_1306421416.rar"></a>

<a href="http://down.51cto.com/data/2358244" target="_blank">附件:http://down.51cto.com/data/2358244</a>

    本文轉自xshf12345 51CTO部落格,原文連結:http://blog.51cto.com/alexis/575090,如需轉載請自行聯系原作者

繼續閱讀