简体   繁体   English

如何隐藏装饰物?

[英]How to hide an adorner?

I have tried to hide/show an adorner of a specific element: 我试图隐藏/显示特定元素的装饰物:

1) by trying to hide the adorned element, but with no success. 1)试图隐藏装饰元素,但没有成功。

2) by using the following code, but when i apply it to the specific element, all other adorners are hidden (the elements are placed on different canvases). 2)通过使用以下代码,但是当我将其应用于特定元素时,所有其他装饰物都被隐藏(元素放置在不同的画布上)。

Public Shared Sub ChangeAdornerLabelLineVisibility(ByRef line As Line, ByVal isAdornerVisible As Boolean)

    Dim lineAdornerLayer As AdornerLayer

    Try

        lineAdornerLayer = AdornerLayer.GetAdornerLayer(line)

        If isAdornerVisible Then

            lineAdornerLayer.Visibility = Windows.Visibility.Visible

        Else

            lineAdornerLayer.Visibility = Windows.Visibility.Hidden

        End If

    Catch

    End Try

End Sub

How can i hide the adorner of a specific element? 如何隐藏特定元素的装饰物?

You shouldnt be hiding the adornerlayer, instead you should just remove the adorner from the adorner layer and it will disappear. 您不应该隐藏装饰层,而应该从装饰层中删除装饰层,它会消失。

For example you have an adorner as below 例如,您有一个如下的装饰器

LineAdorner adorner = new LineAdorner();
lineAdornerLayer = AdornerLayer.GetAdornerLayer(line)
//To Show the Adorner
lineAdornerLayer.Add(adorner);
//To hide the Adorner
lineAdornerLayer.Remove(adorner);

sorry i used c# syntax I am sure you can convert that to vb. 抱歉,我使用了C#语法,我相信您可以将其转换为vb。 Let me know if there is any problem 让我知道是否有任何问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM