歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Windows Phone 7 應用升級 Windows Phone 8 方案預覽 選擇合適的 Key Feature

Windows Phone 7 應用升級 Windows Phone 8 方案預覽 選擇合適的 Key Feature

日期:2017/3/1 9:53:52   编辑:Linux編程

相信很多朋友打算升級自己windows phone 7 的應用了吧,今天給大家介紹一下windows phone 8 新feature。

升級到WP8必需知道的13個特性 系列文章目錄地址:http://www.linuxidc.com/Linux/2013-08/89003.htm

首先著重介紹一下可以為你的應用增色不少而且實現簡單的 Key feature:

1. 應用程序快速恢復 Fast app resume

相信大家知道在之前的WP7應用中將應用切換到後台後只有用back按鈕和FAS可以講應用程序再次恢復,如果使用應用列表中的按鈕或Tile啟動都會使原有的應用程序終止並且創建一個新的應用實例,在windows phone 8 中解決了這個問題,但是不是默認程序都支持Fast app resume的,需要開發者做一個小調整我在這裡先給大家簡單介紹一下:

1.1 啟動 Fast resume 非常簡單只需要你在 app manifest 文件中更改一下你的設置

右鍵編輯你的 manifest 文件找到 Tasks文件夾下的 DefaultTask 節點添加一個 ActivationPolicy 屬性值為 Resume, 此時你就實現了 fast app resume。

<Tasks>
<DefaultTask Name="_default" NavigationPage="MainPage.xaml" ActivationPolicy="Resume"/>
</Tasks>

2.2 當然你可以優化你的應用程序從在不同的情況跳轉至不同的頁面 例如:開始頁面的Tile和應用列表頁或者使用Deep link打開的情況 做分別處理.

具體方法是在應用程序在Activated & Navigating 時候進行判斷

// Code to execute when the application is activated (brought to foreground)
// This code will not execute when the application is first launched
private void Application_Activated(object sender, ActivatedEventArgs e)
{
mustClearPagestack = CheckDeactivationTimeStamp();
}

void RootFrame_Navigating(object sender, NavigatingCancelEventArgs e)

e.NavigationMode == NavigationMode.New

請大家根據自己程序的需要進行設配目前我自己測試的結果來看還是可以較好的保存 NavigationService.BackStack 中的記錄的。

這裡給出一個 MSDN連接:http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj735579(v=vs.105).aspx

2. 全新的 live tiles Support Large Tiles

WP8 支持三種尺寸的Tile分別是:small,medium,wide。

wide 也是在WP8中新支持的Tile 可以占據用戶Tile頁面的整行超值的一個feature :)

當然還有三種不同的 Tile Templates: Flip Iconic 和 Cycle

Flip 和之前WP7的效果十分相似就是圖片和文字的一個翻轉效果如下所示:

同樣支持 推送和後台更新創建:

C# code

FlipTileData TileData = new FlipTileData()
{
Title = "[title]",
BackTitle = "[back of Tile title]",
BackContent = "[back of medium Tile size content]",
WideBackContent = "[back of wide Tile size content]",
Count = [count],
SmallBackgroundImage = [small Tile size URI],
BackgroundImage = [front of medium Tile size URI],
BackBackgroundImage = [back of medium Tile size URI],
WideBackgroundImage = [front of wide Tile size URI],
WideBackBackgroundImage = [back of wide Tile size URI],
};

XAML 模板

<?xml version="1.0" encoding="utf-8"?>
<wp:Notification xmlns:wp="WPNotification" Version="2.0">
<wp:Tile Id="[Tile ID]" Template="FlipTile">
<wp:SmallBackgroundImage [Action="Clear"]>[small Tile size URI]</wp:SmallBackgroundImage>
<wp:WideBackgroundImage Action="Clear">[front of wide Tile size URI]</wp:WideBackgroundImage>
<wp:WideBackBackgroundImage Action="Clear">[back of wide Tile size URI]</wp:WideBackBackgroundImage>
<wp:WideBackContent Action="Clear">[back of wide Tile size content]</wp:WideBackContent>
<wp:BackgroundImage Action="Clear">[front of medium Tile size URI]</wp:BackgroundImage>
<wp:Count Action="Clear">[count]</wp:Count>
<wp:Title Action="Clear">[title]</wp:Title>
<wp:BackBackgroundImage Action="Clear">[back of medium Tile size URI]</wp:BackBackgroundImage>
<wp:BackTitle Action="Clear">[back of Tile title]</wp:BackTitle>
<wp:BackContent Action="Clear">[back of medium Tile size content]</wp:BackContent>
</wp:Tile>
</wp:Notification>

Iconic Tile

Iconic 也是windows phone 8 所特有的,目前多用於系統內置的應用 例如郵件短信等。

三種尺寸效果

代碼模板

XAML

<?xml version="1.0" encoding="utf-8"?>
<wp:Notification xmlns:wp="WPNotification" Version="2.0">
<wp:Tile Id="[Tile ID]" Template="IconicTile">
<wp:SmallIconImage [Action="Clear"]>[small Tile size URI]</wp:SmallIconImage>
<wp:IconImage Action="Clear">[medium/wide Tile size URI]</wp:IconImage>
<wp:WideContent1 Action="Clear">[1st row of content]</wp:WideContent1>
<wp:WideContent2 Action="Clear">[2nd row of content]</wp:WideContent2>
<wp:WideContent3 Action="Clear">[3rd row of content]</wp:WideContent3>
<wp:Count Action="Clear">[count]</wp:Count>
<wp:Title Action="Clear">[title]</wp:Title>
<wp:BackgroundColor Action="Clear">[hex ARGB format color]</wp:BackgroundColor>
</wp:Tile>
</wp:Notification>

C# 創建模板

IconicTileData TileData = new IconicTileData()
{
Title = "[title]",
Count = [count],
WideContent1 = "[1st row of content]",
WideContent2 = "[2nd row of content]",
WideContent3 = "[3rd row of content]",
SmallIconImage = [small Tile size URI],
IconImage = [medium/wide Tile size URI],
BackgroundColor = [.NET color type of Tile]
};
Copyright © Linux教程網 All Rights Reserved