Click here to Skip to main content
15,886,199 members
Articles / Desktop Programming / WPF

WPF.JoshSmith

Rate me:
Please Sign up or sign in to vote.
4.99/5 (51 votes)
13 Jul 2008CPOL5 min read 389.7K   4.8K   263  
A free library of controls and utility classes for use in WPF applications.
// Copyright (C) Josh Smith - February 2007
using System;
using System.Collections;
using System.Windows;

namespace WPF.JoshSmith.Adorners
{
    /// <summary>
    /// An adorner which can display one and only one UIElement.  The element
    /// is added to the adorner's visual and logical trees, enabling it to 
    /// particpate in dependency property value inheritance, amongst other things.
    /// </summary>
    /// <remarks>
    /// Used In: http://www.codeproject.com/KB/WPF/SmartTextBox.aspx
    /// </remarks>
    public class UIElementAdorner : SingleChildAdornerBase
    {
        #region Constructor

        /// <summary>
        /// Constructor.  Adds 'childElement' to the adorner's visual and logical trees.
        /// </summary>
        /// <param name="adornedElement">The element to which the adorner will be bound.</param>
        /// <param name="childElement">The element to be displayed in the adorner.</param>
        public UIElementAdorner(UIElement adornedElement, UIElement childElement)
            : base(adornedElement)
        {
            if (childElement == null)
                throw new ArgumentNullException("childElement");

            this.child = childElement;
            this.AddLogicalChild(childElement);
            this.AddVisualChild(childElement);
        }

        #endregion // Constructor

        #region Base Class Overrides

        /// <summary>
        /// Override.
        /// </summary>
        protected override IEnumerator LogicalChildren
        {
            get
            {
                ArrayList list = new ArrayList();
                list.Add(this.child);
                return list.GetEnumerator();
            }
        }

        #endregion // Base Class Overrides
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
Josh creates software, for iOS and Windows.

He works at Black Pixel as a Senior Developer.

Read his iOS Programming for .NET Developers[^] book to learn how to write iPhone and iPad apps by leveraging your existing .NET skills.

Use his Master WPF[^] app on your iPhone to sharpen your WPF skills on the go.

Check out his Advanced MVVM[^] book.

Visit his WPF blog[^] or stop by his iOS blog[^].

See his website Josh Smith Digital[^].

Comments and Discussions