SystemTray控件也就是显示电池信号量的区域空间(如图)
它可以做進度提示、广告等。
1 SystemTray.BackgroundColor="<背景顏色>" 2 SystemTray.ForegroundColor="<前景顏色>" 3 SystemTray.Opacity="<透明度>" 4 SystemTray.IsVisible="<啟動時是否顯示>"> 5 SystemTray.ProgressIndicatorProperty="<设置进度指示器(ProgressIndicator)>"
下面是一个简单的使用例子
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Net; 5 using System.Windows; 6 using System.Windows.Controls; 7 using System.Windows.Documents; 8 using System.Windows.Input; 9 using System.Windows.Media; 10 using System.Windows.Media.Animation; 11 using System.Windows.Shapes; 12 using Microsoft.Phone.Controls; 13 using Microsoft.Phone.Shell; 14 using System.Windows.Threading; 15 namespace TestSystemTray 16 { 17 public partial class MainPage : PhoneApplicationPage 18 { 19 // 建構函式 20 public MainPage() 21 { 22 InitializeComponent(); 23 } 24 private void button1_Click(object sender, RoutedEventArgs e) 25 { 26 ProgressIndicator _mangoIndicator = new ProgressIndicator(); 27 DispatcherTimer _timer = new DispatcherTimer(); 28 _timer.Interval = TimeSpan.FromSeconds(2); 29 _timer.Tick += (obj, args) => 30 { 31 _mangoIndicator.IsVisible = false; 32 ClearValue(SystemTray.ProgressIndicatorProperty); 33 ClearValue(SystemTray.OpacityProperty); 34 ClearValue(SystemTray.BackgroundColorProperty); 35 ClearValue(SystemTray.ForegroundColorProperty); 36 (obj as DispatcherTimer).Stop(); 37 obj = null; 38 }; 39 _mangoIndicator.IsVisible = true; 40 _mangoIndicator.Text = "不管你信不信,反正我信了"; 41 _mangoIndicator.IsIndeterminate = true; 42 SetValue(SystemTray.ProgressIndicatorProperty, _mangoIndicator); 43 SetValue(SystemTray.OpacityProperty, 0.9); 44 SetValue(SystemTray.BackgroundColorProperty, Colors.Yellow); 45 SetValue(SystemTray.ForegroundColorProperty, Colors.Blue); 46 SystemTray.IsVisible = true; 47 _timer.Start(); 48 } 49 } 50 }
运行效果
本文同步发表于:卤面网
http://www.hugwp.com/article-404-1.html
参考:http://blogs.msdn.com/b/ericsk/archive/2011/08/03/wp7-systemtray-progress-indication.aspx