WPF框架对象的生命周期

本文探讨了WPF框架级别元素(从FrameworkElement或FrameworkContentElement派生的对象)的生命周期。初始化(Initialized)事件在元素树(包括视觉树和逻辑树)中的顺序不确定,而加载(Loaded)事件则遵循从父到子的顺序依次触发。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

所谓框架对象--WPF framework-level element (those objects deriving from either FrameworkElement or FrameworkContentElement)

的生命周期见这里

值得注意的是Initialized事件的顺序在树(包括视觉树和逻辑树)的顺序是不确定的。而loaded事件居然是从父到子的。

The mechanism by which the Loaded event is raised is different than Initialized. The Initialized event is raised element by element, without a direct coordination by a completed element tree. By contrast, the Loaded event is raised as a coordinated effort throughout the entire element tree (specifically, the logical tree). When all elements in the tree are in a state where they are considered loaded, the Loaded event is first raised on the root element. The Loaded event is then raised successively on each child element.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值