惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
I
InfoQ
D
DataBreaches.Net
Simon Willison's Weblog
Simon Willison's Weblog
F
Fortinet All Blogs
Help Net Security
Help Net Security
P
Proofpoint News Feed
F
Full Disclosure
G
GRAHAM CLULEY
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
G
Google Developers Blog
T
The Blog of Author Tim Ferriss
P
Palo Alto Networks Blog
T
Threat Research - Cisco Blogs
H
Hackread – Cybersecurity News, Data Breaches, AI and More
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Microsoft Azure Blog
Microsoft Azure Blog
T
Threatpost
C
CXSECURITY Database RSS Feed - CXSecurity.com
The Register - Security
The Register - Security
The Hacker News
The Hacker News
Scott Helme
Scott Helme
T
Tor Project blog
Recorded Future
Recorded Future
Blog — PlanetScale
Blog — PlanetScale
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
V
Vulnerabilities – Threatpost
Vercel News
Vercel News
L
Lohrmann on Cybersecurity
Know Your Adversary
Know Your Adversary
T
The Exploit Database - CXSecurity.com
IT之家
IT之家
C
Check Point Blog
NISL@THU
NISL@THU
Engineering at Meta
Engineering at Meta
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
LangChain Blog
S
Schneier on Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
CERT Recently Published Vulnerability Notes
博客园 - 三生石上(FineUI控件)
Spread Privacy
Spread Privacy
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
L
LINUX DO - 最新话题
S
Security @ Cisco Blogs
The Cloudflare Blog

博客园 - MainTao

WebStorm 自定义字体+颜色+语法高亮+导入导出用户设置 WebStorm安装Vim以及快捷键设置 scroll clock–jQuery widget implement 基于iScroll 的开发(不断补充) C#操作Win7/Win8的库、收藏夹 P/Invoke Interop 实例 WP7图片从独立存储绑定 编写jQueryUI插件(widget) 调试Javascript Windows Phone 7监测网络环境变化 Blend制作动画 用OpacityMask快速制作theme friendly UI 用gradient brush和OpacityMask实现fade edge效果 blend 画图 ControlTemplate & DataTemplate Windows Phone 7 短信表情 WP7应用程序生命周期,以及各个event handler分别该做什么 第一个WP7程序 开发总结 XAML中的空格、换行、Tab
PhoneApplicationFrame以及设置Obscured/Unobscured的event handler
MainTao · 2011-12-01 · via 博客园 - MainTao

image

简单描述Sliverlight程序,就是在一个Frame里不停地换Page。在App.xaml.cs里,那个RootFrame(VisualRoot)就是PhoneApplicationFrame类型。

MSDN上关于PhoneApplicationFrame的解释已经做得简洁易读:http://msdn.microsoft.com/en-us/library/ff402536%28v=VS.92%29.aspx

我就不再赘述了,只简单总结一下:

PhoneApplicationFrame掌管着:

页面上方的Status Bar和下方的Application Bar

监听事件:页面方向的切换(Portrait/Landscape),Back按钮被按下,由来电等触发的Obscured/UnObscured等。其中大多事件都能由Page监听,在XAML里直接指定event handler就很方便,但是Obscured/UnObscured事件无法在Page中找到,这才需要在code behind里用到PhoneApplicationFrame,代码如下:

PhoneApplicationFrame frame = (PhoneApplicationFrame)Application.Current.RootVisual;
frame.Obscured += new EventHandler<ObscuredEventArgs>(frame_Obscured);
frame.Unobscured += new EventHandler(frame_Unobscured);

当Obscured发生时,无法知道具体由什么中断的,只能知道是不是由锁屏中断的:

void frame_Obscured(object sender, ObscuredEventArgs e)
{
    if (e.IsLocked) // 仅能判断是否是锁屏
    {
    }
}
Obscured事件触发的时机

例如当电话来的时候就会触发Obscured事件,如果你正在玩游戏之类的,便可以在obscured的hander中使游戏暂停。这时候还没触发Deactived事件,只有当用户按下接听按钮时,才会触发Deactived事件。如果是锁屏的话,Obscured事件也会先于Deactivated事件发生。