震动

VibrateController.Default.Start(TimeSpan.FromSeconds(.5));
参数是振动时间长度,上限是5秒钟。
VibrateController.Default.Stop();
用户在手机的设置里关掉了震动也不会影响app的震动,只会影响到短信来电等。
 
 

让程序在手机Lock的时候保持运行

有两个全局变量,分别适用于不同的场景:

PhoneApplicationService.Current.ApplicationIdleDetectionMode禁用之后,超时会关显示器和锁定,但仍然运行,例如GPS计里程应用和音乐播放。

PhoneApplicationService.Current.UserIdleDetectionMode禁用之后,超时不会关显示器和锁定,例如视频应用。

一旦disable之后,在程序本次运行中无法再enable,只有重新启动才可以enable。

// Allow the app to run (and vibrate) even when the phone is locked.
// Once disabled, you cannot re-enable the default behavior!
PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled;
 
批量初始化button
// Fill the wrap panel with the 90 buttons
for (int i = 0; i < this.buttons.Length; i++)
{
  this.buttons[i] = new Button
  {
    // Each button contains a square, invisible (Fill=null) when off and accent-colored when on
    Content = new Rectangle {
      Margin = new Thickness(0, 7, 0, 5),
      Width = 30, Height = 30
    }
  };
  this.buttons[i].Click += Button_Click;
  this.WrapPanel.Children.Add(this.buttons[i]);
}

 

LineBreak

在XAML中用<LineBreak/>来表示回车,而不是\r\n。

posted on 2011-10-16 23:25  MainTao  阅读(470)  评论(0编辑  收藏  举报