wp7利用 SystemTray 做进度条提示 (Mango)
Windows Phone 7 在 Mango 更新(Windows Phone 7.5)之後新增了不少 APIs,其中一個部份就是能在程式中操作 SystemTray 的控制項,這個控制項本身就有提供 ProgressIndicator 的物件設計,所以很適合用來做為讀取中的提示訊息。
使用 SystemTray 可以從設計介面的 XAML 檔案以及程式碼來下手,首先如果要在 XAML 中最上層的 <phone:PhoneApplicationPage>標籤中加入下列的屬性:
<phone:PhoneApplicationpage ... xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" ... shell:SystemTray.BackgroundColor="<背景顏色>" shell:SystemTray.ForegroundColor="<前景顏色>" shell:SystemTray.Opacity="<透明度>" shell:SystemTray.IsVisible="<啟動時是否顯示>"> ... </phone:phoneapplicationpage>
這些屬性是用來指定 SystemTray 控制項一些基本視覺元素,但光是這樣還沒辦法讓它成為讀取的提示,還需要在程式裡面指定 ProgressIndicator 才行,程式的操作範例如下:
using Microsoft.Phone.Shell; ... // 建立 ProgressIndicator 並設定給 SystemTray ProgressIndicator pi = new ProgressIndicator(); pi.Text = "Loading..."; pi.IsIndeterminate = true; pi.IsVisible = true; SystemTray.SetProgressIndicator(this, pi); ... // 讓 SystemTray 顯示或隱藏 SystemTray.IsVisible = <true|false>;
這樣做出來的效果就會像是這樣(BackgrounColor="Blue" ForegroundColor="White"):
转处:http://blogs.msdn.com/b/ericsk/archive/2011/08/03/wp7-systemtray-progress-indication.aspx
浙公网安备 33010602011771号