Click here to Skip to main content
15,886,873 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 342.1K   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;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;

#endregion


namespace ZonaTools.XPlorerBar
{
    /// <summary>
    /// Converts a SolidColorBrush type to a Color type  
    /// </summary>
    [ValueConversion(typeof(SolidColorBrush), typeof(Color))]
    class SolidColorBrushToColorConverter : IValueConverter
    {
        //===========================================================================
        /// <summary>
        /// Converts a SolidColorBrush type to a Color type.
        /// </summary>
        /// <param name="value">SolidColorBrush to be converted.</param>
        /// <param name="targetType">Type, the value is to be converted to.</param>
        /// <param name="parameter">Not used here.</param>
        /// <param name="culture">Not used here.</param>
        /// <returns>Created color.</returns>
        //===========================================================================
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            //Gets the value to convert
            SolidColorBrush brush = value as SolidColorBrush;

            //Checks the type of the value to convert and return a color if possible
            if (brush != null)
                return brush.Color;
            else
                return Binding.DoNothing;
        }


        //===========================================================================
        /// <summary>
        /// Converts a Color type to a SolidColorBrush type.
        /// </summary>
        /// <param name="value">Color to be converted.</param>
        /// <param name="targetType">Type, the value is to be converted to.</param>
        /// <param name="parameter">Not used here.</param>
        /// <param name="culture">Not used here.</param>
        /// <returns>Created SolidColor brush.</returns>
        //===========================================================================
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            //Checks if there is a value to convert
            if (value == null)
                return null;

            //Checks the type of the value to convert
            if (!(value is Color))
                throw new ArgumentException("Value of 'Color' type is expected.", "value");

            //Gets the value to convert
            Color color = (Color)value;

            return new SolidColorBrush(color);
        }
    }
}

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