Silverlight 的控件生命周期

微软的 Dave Relyea 在 blog 中解释了 Silverlight 中控件的生命周期,以及一些可以 override 的基类方法发生的时机。

http://blogs.msdn.com/devdave/archive/2008/10/11/control-lifecycle.aspx

ActionControl instantiated in XAMLControl instantiated in code
Control ctorAs soon as begin tag is parsed. When you call it.
Explicit Style appliedIf the Style property is set in XAML, it will be applied as soon as the end tag is parsed.As soon as Style property is set.
Built-in Style (from generic.xaml) appliedAs soon as the end tag is parsed, after the explicit Style (if any) has been applied. Will not override explicit Style.When the control enters the tree. Will not override explicit Style.
Properties setWhen the attributes are parsed.When you set them.
Loaded eventPosted when the element is been added to the tree. Fired before the next frame. Happens before layout.Same.
Template applied (i.e. control's visual are created from the Template)In the Measure pass of layout. The Template property will be applied if the control has no visual tree. The control starts life with no visual tree, and the visual tree will be cleared when the Template property is set. You can also call ApplyTemplate yourself.Same.
OnApplyTemplate calledWhenever the Template is applied. It is not necessary to call the base OnApplyTemplate for the Template to be applied, but inherited types might be relying on it for their implementations.Same.
Visuals first availableIn OnApplyTemplate. Use GetTemplateChild.Same.
MeasureOverride calledIn the Measure pass of layout. If the Template was expanded during this Measure pass, MeasureOverride will be called after the Template has been expanded.Same.
ArrangeOverride calledIn the Arrange pass of layout, which occurs after the Measure pass.Same.
SizeChanged eventAfter the Measure and Arrange passes have completed.Same.
LayoutUpdated eventAfter SizeChanged events have fired.Same.

 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值