简体   繁体   English

在画布上设置DrawingVisual的可见性(可见,不可见)

[英]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.

相关问题 在画布上显示DrawingVisual - Display a DrawingVisual on Canvas 控件不可见,即使可见性设置为可见 - Control not visible even visibility set to visible 如何在XAML中定义的Canvas的子UIElement上方的画布上显示drawingvisual - how to display drawingvisual on canvas above child UIElements of Canvas defined in XAML 如何在可见的情况下将可见性设置为折叠的图像 - How to set visibility to collapsed on image when one is visible 渲染(重绘)不可见的画布 - Render (redraw) the invisible canvas 墓碑画布可见性属性 - Tombstoning Canvas Visibility Property 将标签的可见性设置为false后,如何使标签再次可见? - How do you make labels visible again once their visibility is set to false? 如何在 XAML 中设置 label 的可见性,使其在 label 的 Text 属性不是 null 的情况下变得可见? - How can I set the visibility of a label in XAML so it becomes visible where the Text property of that label is not null? c# 无法将父控件的可见性设置为“可见”,将子控件的可见性设置为“已折叠” - c# cannot set visibility of parent control to 'Visible' and child control to 'Collapsed' 在从一页导航到另一页时,一旦其可见性设置为false,则按钮不可见 - Button is not getting visible once its visibility set to false while navigating from one page to another
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM