[英]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? 除了将其从画布中删除(用于不可见性)并使用存储在某处的信息重新绘制以使其再次可见之外,是否可以设置DrawingVisual对象的可见性?
I want to do it after DrawingContext of the DrawingVisual has been closed. 我想在DrawingVisual的DrawingContext关闭后执行此操作。
DrawingVisual
doesn't have Visibility
property, as it doesn't derive from FrameworkElement
. DrawingVisual
没有Visibility
属性,因为它不是从FrameworkElement
派生的。
So you cannot do that that easily. 因此,您不能轻易做到这一点。 However, you can make it transparent, by adjusting
VisualOpacity
on it. 但是,可以通过调整
VisualOpacity
使其透明。 The MSDN doc says, MSDN文档说,
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.
Visual的不透明度值表示为0到1之间的值。 值0表示元素是完全透明的 ,而值1表示元素是完全不透明的。 A value of 0.5 indicates that the element is 50 percent opaque.
值为0.5表示元素为50%不透明。 Values that are less than 0 are treated as 0;
小于0的值视为0;小于0的值视为0。 values that are greater than 1 are treated as 1.
大于1的值将被视为1。
Hope that helps. 希望有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.