改变冻结物体的可见性?
我正在尝试优化我的 WPF/VB.net 程序,并且正在考虑冻结一些对象。然而,虽然我知道以任何方式动画的对象都不能被冻结,但我需要知道......您可以更改冻结对象的可见性吗?
谢谢你!
I'm trying to optimize my WPF/VB.net program, and I'm considering freezing some objects. However, while I know that an object that is animated in any way cannot be frozen, I need to know...can you change the visibility of a frozen object?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从概念上来说,冻结
Freezable
对象会使其不可变,因此尝试写入任何可写属性都会引发异常,包括Visibility
。但是,您可以通过将 Freezable 对象包含在不可冻结对象中来隐式影响它的状态。例如,您可以使用Grid
或任何其他Panel
作为包装器并切换容器的Visibility
,它将影响看似不可变的内容间接冻结对象。话虽这么说,冻结并不能真正提高效率,除非您要复制该对象的大量副本。Freezing a
Freezable
object conceptually makes it immutable so an attempt to write to any writable properties should throw an exception, includingVisibility
. You can however implicitly affect aFreezable
object's state by containing it in a non-freezable object. For example, you can use aGrid
or any otherPanel
as a wrapper and toggle theVisibility
of the container and it will affect the seemingly immutable frozen object indirectly. That being said, freezing doesn't really buy you very much efficiency-wise unless you are making quite a lot of copies of the object.