wpfvb.netvisibilityfreezable

Changing the visibility of a frozen object?


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!


Solution

  • Freezing a Freezable object conceptually makes it immutable so an attempt to write to any writable properties should throw an exception, including Visibility. You can however implicitly affect a Freezable object's state by containing it in a non-freezable object. For example, you can use a Grid or any other Panel as a wrapper and toggle the Visibility 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.