Click here to Skip to main content
15,881,803 members
Articles / Desktop Programming / WPF

XPlorerBar: A WPF Windows XP Style Explorer Bar Control

Rate me:
Please Sign up or sign in to vote.
4.95/5 (168 votes)
9 Dec 2008CPOL11 min read 340.6K   9.3K   408  
A fully customizable WPF implementation of the left side pane that was introduced in Windows XP's Explorer.
#region [       Copyright © 2008, Zona-Tools, all rights reserved.       ]
/*
 * 
    This source code is licensed under the Code Project Open License (CPOL).
    Check out http://www.codeproject.com/info/cpol10.aspx for further details.
 * 
*/
#endregion


#region [       Using namespaces       ]

using System.Windows;

#endregion


namespace ZonaTools.XPlorerBar
{
    /// <summary>
    /// Declares static resource keys for all the resources to share
    /// with another assembly.
    /// </summary>
    public static class XPlorerResourceKeys
    {
        #region [       XPlorerBar brushes       ]

        /// <summary>
        /// Gets the <c>XPlorerBarBackgroundBrush</c> brush.
        /// </summary>
        public static ComponentResourceKey XPlorerBarBackgroundBrushKey
        {
            get { return GetRegisteredKey(_XPlorerBarBackgroundBrushKey, "XPlorerBarBackgroundBrush"); }
        }
        private static ComponentResourceKey _XPlorerBarBackgroundBrushKey = null;

        #endregion


        #region [       XPlorerSection content brushes       ]

        /// <summary>
        /// Gets the <c>XPlorerSectionContentBackgroundBrush</c> brush.
        /// </summary>
        public static ComponentResourceKey XPlorerSectionContentBackgroundBrushKey
        {
            get { return GetRegisteredKey(_XPlorerSectionContentBackgroundBrushKey, "XPlorerSectionContentBackgroundBrush"); }
        }
        private static ComponentResourceKey _XPlorerSectionContentBackgroundBrushKey = null;

        /// <summary>
        /// Gets the <c>XPlorerSectionContentForegroundBrush</c> brush.
        /// </summary>
        public static ComponentResourceKey XPlorerSectionContentForegroundBrushKey
        {
            get { return GetRegisteredKey(_XPlorerSectionContentForegroundBrushKey, "XPlorerSectionContentForegroundBrush"); }
        }
        private static ComponentResourceKey _XPlorerSectionContentForegroundBrushKey = null;

        /// <summary>
        /// Gets the <c>XPlorerSectionContentHoverForegroundBrush</c> brush.
        /// </summary>
        public static ComponentResourceKey XPlorerSectionContentHoverForegroundBrushKey
        {
            get { return GetRegisteredKey(_XPlorerSectionContentHoverForegroundBrushKey, "XPlorerSectionContentHoverForegroundBrush"); }
        }
        private static ComponentResourceKey _XPlorerSectionContentHoverForegroundBrushKey = null;

        /// <summary>
        /// Gets the <c>XPlorerSectionContentBorderBrush</c> brush.
        /// </summary>
        public static ComponentResourceKey XPlorerSectionContentBorderBrushKey
        {
            get { return GetRegisteredKey(_XPlorerSectionContentBorderBrushKey, "XPlorerSectionContentBorderBrush"); }
        }
        private static ComponentResourceKey _XPlorerSectionContentBorderBrushKey = null;

        #endregion


        #region [       XPlorerSection content brushes (IsPrimary = true)       ]

        /// <summary>
        /// Gets the <c>XPlorerSectionPrimaryContentBackgroundBrush</c> brush.
        /// </summary>
        public static ComponentResourceKey XPlorerSectionPrimaryContentBackgroundBrushKey
        {
            get { return GetRegisteredKey(_XPlorerSectionPrimaryContentBackgroundBrushKey, "XPlorerSectionPrimaryContentBackgroundBrush"); }
        }
        private static ComponentResourceKey _XPlorerSectionPrimaryContentBackgroundBrushKey = null;

        /// <summary>
        /// Gets the <c>XPlorerSectionPrimaryContentForegroundBrush</c> brush.
        /// </summary>
        public static ComponentResourceKey XPlorerSectionPrimaryContentForegroundBrushKey
        {
            get { return GetRegisteredKey(_XPlorerSectionPrimaryContentForegroundBrushKey, "XPlorerSectionPrimaryContentForegroundBrush"); }
        }
        private static ComponentResourceKey _XPlorerSectionPrimaryContentForegroundBrushKey = null;

        /// <summary>
        /// Gets the <c>XPlorerSectionPrimaryContentHoverForegroundBrush</c> brush.
        /// </summary>
        public static ComponentResourceKey XPlorerSectionPrimaryContentHoverForegroundBrushKey
        {
            get { return GetRegisteredKey(_XPlorerSectionPrimaryContentHoverForegroundBrushKey, "XPlorerSectionPrimaryContentHoverForegroundBrush"); }
        }
        private static ComponentResourceKey _XPlorerSectionPrimaryContentHoverForegroundBrushKey = null;

        /// <summary>
        /// Gets the <c>XPlorerSectionPrimaryContentBorderBrush</c> brush.
        /// </summary>
        public static ComponentResourceKey XPlorerSectionPrimaryContentBorderBrushKey
        {
            get { return GetRegisteredKey(_XPlorerSectionPrimaryContentBorderBrushKey, "XPlorerSectionPrimaryContentBorderBrush"); }
        }
        private static ComponentResourceKey _XPlorerSectionPrimaryContentBorderBrushKey = null;

        #endregion


        #region [       XPlorerSection header brushes       ]

        /// <summary>
        /// Gets the <c>XPlorerSectionHeaderBackgroundBrush</c> brush.
        /// </summary>
        public static ComponentResourceKey XPlorerSectionHeaderBackgroundBrushKey
        {
            get { return GetRegisteredKey(_XPlorerSectionHeaderBackgroundBrushKey, "XPlorerSectionHeaderBackgroundBrush"); }
        }
        private static ComponentResourceKey _XPlorerSectionHeaderBackgroundBrushKey = null;

        /// <summary>
        /// Gets the <c>XPlorerSectionHeaderForegroundBrush</c> brush.
        /// </summary>
        public static ComponentResourceKey XPlorerSectionHeaderForegroundBrushKey
        {
            get { return GetRegisteredKey(_XPlorerSectionHeaderForegroundBrushKey, "XPlorerSectionHeaderForegroundBrush"); }
        }
        private static ComponentResourceKey _XPlorerSectionHeaderForegroundBrushKey = null;

        /// <summary>
        /// Gets the <c>XPlorerSectionHeaderHoverForegroundBrush</c> brush.
        /// </summary>
        public static ComponentResourceKey XPlorerSectionHeaderHoverForegroundBrushKey
        {
            get { return GetRegisteredKey(_XPlorerSectionHeaderHoverForegroundBrushKey, "XPlorerSectionHeaderHoverForegroundBrush"); }
        }
        private static ComponentResourceKey _XPlorerSectionHeaderHoverForegroundBrushKey = null;

        /// <summary>
        /// Gets the <c>XPlorerSectionHeaderButtonBackgroundBrush</c> brush.
        /// </summary>
        public static ComponentResourceKey XPlorerSectionHeaderButtonBackgroundBrushKey
        {
            get { return GetRegisteredKey(_XPlorerSectionHeaderButtonBackgroundBrushKey, "XPlorerSectionHeaderButtonBackgroundBrush"); }
        }
        private static ComponentResourceKey _XPlorerSectionHeaderButtonBackgroundBrushKey = null;

        /// <summary>
        /// Gets the <c>XPlorerSectionHeaderButtonForegroundBrush</c> brush.
        /// </summary>
        public static ComponentResourceKey XPlorerSectionHeaderButtonForegroundBrushKey
        {
            get { return GetRegisteredKey(_XPlorerSectionHeaderButtonForegroundBrushKey, "XPlorerSectionHeaderButtonForegroundBrush"); }
        }
        private static ComponentResourceKey _XPlorerSectionHeaderButtonForegroundBrushKey = null;

        /// <summary>
        /// Gets the <c>XPlorerSectionHeaderButtonHoverForegroundBrush</c> brush.
        /// </summary>
        public static ComponentResourceKey XPlorerSectionHeaderButtonHoverForegroundBrushKey
        {
            get { return GetRegisteredKey(_XPlorerSectionHeaderButtonHoverForegroundBrushKey, "XPlorerSectionHeaderButtonHoverForegroundBrush"); }
        }
        private static ComponentResourceKey _XPlorerSectionHeaderButtonHoverForegroundBrushKey = null;

        /// <summary>
        /// Gets the <c>XPlorerSectionHeaderButtonBorderBrush</c> brush.
        /// </summary>
        public static ComponentResourceKey XPlorerSectionHeaderButtonBorderBrushKey
        {
            get { return GetRegisteredKey(_XPlorerSectionHeaderButtonBorderBrushKey, "XPlorerSectionHeaderButtonBorderBrush"); }
        }
        private static ComponentResourceKey _XPlorerSectionHeaderButtonBorderBrushKey = null;

        #endregion


        #region [       XPlorerSection header brushes (IsPrimary = true)       ]

        /// <summary>
        /// Gets the <c>XPlorerSectionPrimaryHeaderBackgroundBrush</c> brush.
        /// </summary>
        public static ComponentResourceKey XPlorerSectionPrimaryHeaderBackgroundBrushKey
        {
            get { return GetRegisteredKey(_XPlorerSectionPrimaryHeaderBackgroundBrushKey, "XPlorerSectionPrimaryHeaderBackgroundBrush"); }
        }
        private static ComponentResourceKey _XPlorerSectionPrimaryHeaderBackgroundBrushKey = null;

        /// <summary>
        /// Gets the <c>XPlorerSectionPrimaryHeaderForegroundBrush</c> brush.
        /// </summary>
        public static ComponentResourceKey XPlorerSectionPrimaryHeaderForegroundBrushKey
        {
            get { return GetRegisteredKey(_XPlorerSectionPrimaryHeaderForegroundBrushKey, "XPlorerSectionPrimaryHeaderForegroundBrush"); }
        }
        private static ComponentResourceKey _XPlorerSectionPrimaryHeaderForegroundBrushKey = null;

        /// <summary>
        /// Gets the <c>XPlorerSectionPrimaryHeaderHoverForegroundBrush</c> brush.
        /// </summary>
        public static ComponentResourceKey XPlorerSectionPrimaryHeaderHoverForegroundBrushKey
        {
            get { return GetRegisteredKey(_XPlorerSectionPrimaryHeaderHoverForegroundBrushKey, "XPlorerSectionPrimaryHeaderHoverForegroundBrush"); }
        }
        private static ComponentResourceKey _XPlorerSectionPrimaryHeaderHoverForegroundBrushKey = null;

        /// <summary>
        /// Gets the <c>XPlorerSectionPrimaryHeaderButtonBackgroundBrush</c> brush.
        /// </summary>
        public static ComponentResourceKey XPlorerSectionPrimaryHeaderButtonBackgroundBrushKey
        {
            get { return GetRegisteredKey(_XPlorerSectionPrimaryHeaderButtonBackgroundBrushKey, "XPlorerSectionPrimaryHeaderButtonBackgroundBrush"); }
        }
        private static ComponentResourceKey _XPlorerSectionPrimaryHeaderButtonBackgroundBrushKey = null;

        /// <summary>
        /// Gets the <c>XPlorerSectionPrimaryHeaderButtonForegroundBrush</c> brush.
        /// </summary>
        public static ComponentResourceKey XPlorerSectionPrimaryHeaderButtonForegroundBrushKey
        {
            get { return GetRegisteredKey(_XPlorerSectionPrimaryHeaderButtonForegroundBrushKey, "XPlorerSectionPrimaryHeaderButtonForegroundBrush"); }
        }
        private static ComponentResourceKey _XPlorerSectionPrimaryHeaderButtonForegroundBrushKey = null;

        /// <summary>
        /// Gets the <c>XPlorerSectionPrimaryHeaderButtonHoverForegroundBrush</c> brush.
        /// </summary>
        public static ComponentResourceKey XPlorerSectionPrimaryHeaderButtonHoverForegroundBrushKey
        {
            get { return GetRegisteredKey(_XPlorerSectionPrimaryHeaderButtonHoverForegroundBrushKey, "XPlorerSectionPrimaryHeaderButtonHoverForegroundBrush"); }
        }
        private static ComponentResourceKey _XPlorerSectionPrimaryHeaderButtonHoverForegroundBrushKey = null;

        /// <summary>
        /// Gets the <c>XPlorerSectionPrimaryHeaderButtonBorderBrush</c> brush.
        /// </summary>
        public static ComponentResourceKey XPlorerSectionPrimaryHeaderButtonBorderBrushKey
        {
            get { return GetRegisteredKey(_XPlorerSectionPrimaryHeaderButtonBorderBrushKey, "XPlorerSectionPrimaryHeaderButtonBorderBrush"); }
        }
        private static ComponentResourceKey _XPlorerSectionPrimaryHeaderButtonBorderBrushKey = null;

        #endregion


        #region [       XPlorerSection header styles       ]

        /// <summary>
        /// Gets the <c>XPlorerSectionHeaderStyle</c> style.
        /// </summary>
        public static ComponentResourceKey XPlorerSectionHeaderStyleKey
        {
            get { return GetRegisteredKey(_XPlorerSectionHeaderStyleKey, "XPlorerSectionHeaderStyle"); }
        }
        private static ComponentResourceKey _XPlorerSectionHeaderStyleKey = null;

        #endregion


        #region [       XPlorerSection header arrows      ]

        /// <summary>
        /// Gets the <c>XPlorerSectionHeaderExpandArrows</c> geometry.
        /// </summary>
        public static ComponentResourceKey XPlorerSectionHeaderExpandArrowsKey
        {
            get { return GetRegisteredKey(_XPlorerSectionHeaderExpandArrowsKey, "XPlorerSectionHeaderExpandArrows"); }
        }
        private static ComponentResourceKey _XPlorerSectionHeaderExpandArrowsKey = null;

        /// <summary>
        /// Gets the <c>XPlorerSectionHeaderCollapseArrows</c> geometry.
        /// </summary>
        public static ComponentResourceKey XPlorerSectionHeaderCollapseArrowsKey
        {
            get { return GetRegisteredKey(_XPlorerSectionHeaderCollapseArrowsKey, "XPlorerSectionHeaderCollapseArrows"); }
        }
        private static ComponentResourceKey _XPlorerSectionHeaderCollapseArrowsKey = null;
        
        #endregion


        #region [       Helpers       ]

        //===========================================================================
        /// <summary>
        /// Gets or creates the specified registered resource key of an element.
        /// </summary>
        /// <param name="resKey">Private resource key of the element.</param>
        /// <param name="resourceId">Resource name of the element.</param>
        /// <returns>Returns the public resource key of the specified element.</returns>
        //===========================================================================
        private static ComponentResourceKey GetRegisteredKey(ComponentResourceKey resKey, string resourceId)
        {
            if (resKey == null)
                resKey = new ComponentResourceKey(typeof(XPlorerResourceKeys), resourceId);

            return resKey;
        }

        #endregion

    }
}

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
Team Leader
France France
I have been developing and managing projects for real-time embedded softwares for eight years. Then, I moved from Paris to the south of France and began to lead a team who was developping Java applications.

My main occupation right now is to continue my journey in the WPF world.

You can check out my blog here. [^]

Comments and Discussions