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

转载于:https://www.cnblogs.com/Hack-ok/archive/2012/08/05/2623546.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值