--- title: "How to: Remove an Adorner from an Element" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "adorners [WPF], removing" ms.assetid: 97cf4d9f-0596-429e-8526-32a30aa4ae99 --- # How to: Remove an Adorner from an Element This example shows how to programmatically remove a specific adorner from a specified . ## Example This verbose code example removes the first adorner in the array of adorners returned by . This example happens to retrieve the adorners on a named *myTextBox*. If the element specified in the call to has no adorners, `null` is returned. This code explicitly checks for a null array, and is best suited for applications where a null array is expected to be relatively common. [!code-csharp[AdornersMiscCode#_RemoveSpecificAdornerLong](~/samples/snippets/csharp/VS_Snippets_Wpf/AdornersMiscCode/CSharp/Window1.xaml.cs#_removespecificadornerlong)] [!code-vb[AdornersMiscCode#_RemoveSpecificAdornerLong](~/samples/snippets/visualbasic/VS_Snippets_Wpf/AdornersMiscCode/visualbasic/window1.xaml.vb#_removespecificadornerlong)] ## Example This condensed code example is functionally equivalent to the verbose example shown above. This code does not explicitly check for a null array, so it is possible that a exception may be raised. This code is best suited for applications where a null array is expected to be rare. [!code-csharp[AdornersMiscCode#_RemoveSpecificAdornerShort](~/samples/snippets/csharp/VS_Snippets_Wpf/AdornersMiscCode/CSharp/Window1.xaml.cs#_removespecificadornershort)] [!code-vb[AdornersMiscCode#_RemoveSpecificAdornerShort](~/samples/snippets/visualbasic/VS_Snippets_Wpf/AdornersMiscCode/visualbasic/window1.xaml.vb#_removespecificadornershort)] ## See also - [Adorners Overview](adorners-overview.md)