Files
docs-desktop/dotnet-desktop-guide/framework/wpf/controls/how-to-remove-all-adorners-from-an-element.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* 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
2020-09-04 09:46:28 -07:00

2.0 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
How to: Remove all Adorners from an Element 03/30/2017
csharp
vb
adorners [WPF], removing
fe5303a3-b76e-4643-aafb-51419032b47b

How to: Remove all Adorners from an Element

This example shows how to programmatically remove all adorners from a specified xref:System.Windows.UIElement.

Example

This verbose code example removes all of the adorners 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#_RemoveAllAdornersLong] [!code-vbAdornersMiscCode#_RemoveAllAdornersLong]

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#_RemoveAllAdornersShort] [!code-vbAdornersMiscCode#_RemoveAllAdornersShort]

See also