How to hide an adorner?

2.3k views Asked by At

I have tried to hide/show an adorner of a specific element:

1) by trying to hide the adorned element, but with no success.

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).

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?

1

There are 1 answers

0
Krishna On

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. Let me know if there is any problem