Question

Basically, I have a panel that draws its children based upon a DependencyProperty (FooProperty).

If FooProperty is true, the child is arranged; otherwise, it is not arranged. The first passthrough is fine, but when a child changes it's FooProperty from true (draw) to false (don't draw) the ArrangeOverride method skips it and the child remains drawn.

I figure instead of skipping the children that should not be drawn I need some way to undraw them?

Was it helpful?

Solution

You don't "undraw" a child item. What happens is when something triggers the ArrangeOverride pass you simply do your math to draw/redraw it.

If you want to "pseudo skip" the item, you can't. Once it is drawn it must be redrawn. But, you can always draw it at Point(0, 0) with a Rect(0, 0). Basically you're boxing it into nothing there.


So is there a way to "truly" undraw the item? Yes, remove it from the collection of InternalChildren somehow. You can do this by removing the item from the Visual Tree or if you're panel is the host panel to an ItemsSource you can remove that item from the ItemsSource collection.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top