SpeedBirdNine
SpeedBirdNine

Reputation: 4676

Set visibility (visible, invisible) of DrawingVisual on a canvas

Is there a way to set visibility of DrawingVisual object other than removing it from the canvas (for invisibility) and redraw it using information stored somewhere to make it visible again?

I want to do it after DrawingContext of the DrawingVisual has been closed.

Upvotes: 1

Views: 944

Answers (1)

Sarfaraz Nawaz
Sarfaraz Nawaz

Reputation: 361372

DrawingVisual doesn't have Visibility property, as it doesn't derive from FrameworkElement.

So you cannot do that that easily. However, you can make it transparent, by adjusting VisualOpacity on it. The MSDN doc says,

The value of the opacity of the Visual is expressed as a value between 0 and 1. A value of 0 indicates that the element is completely transparent, whereas a value of 1 indicates that the element is completely opaque. A value of 0.5 indicates that the element is 50 percent opaque. Values that are less than 0 are treated as 0; values that are greater than 1 are treated as 1.

Hope that helps.

Upvotes: 3

Related Questions