震动
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。
分类:
Windows Phone
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架