* Reset branch for WPF changes * Convert BMP to PNG; fix link-out-of-scope err * Add snippets for WPF... 6794 files!!!! * Add missing snippets * update file updated between migration * Fix paths to include * update breadcrumb and toc * fix index links * fix index links * fix index links * fix markdown
2.0 KiB
title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
| title | ms.date | dev_langs | helpviewer_keywords | ms.assetid | |||
|---|---|---|---|---|---|---|---|
| How to: Remove an Adorner from an Element | 03/30/2017 |
|
|
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 xref:System.Windows.UIElement.
Example
This verbose code example removes the first adorner in the array of adorners returned by xref:System.Windows.Documents.AdornerLayer.GetAdorners%2A. This example happens to retrieve the adorners on a xref:System.Windows.UIElement named myTextBox. If the element specified in the call to xref:System.Windows.Documents.AdornerLayer.GetAdorners%2A 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-csharpAdornersMiscCode#_RemoveSpecificAdornerLong] [!code-vbAdornersMiscCode#_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 xref:System.NullReferenceException exception may be raised. This code is best suited for applications where a null array is expected to be rare.
[!code-csharpAdornersMiscCode#_RemoveSpecificAdornerShort] [!code-vbAdornersMiscCode#_RemoveSpecificAdornerShort]