Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

Auto-filter for Microsoft WPF DataGrid

, 29 Jan 2009
Allows auto filtering functionality for DataGrid columns.
WPFGridFilter.zip
WPFGridFilter
PowerCollections
PowerCollections.csproj.user
Properties
Stepi.Collections
bin
Filters
Properties
Stepi.UIFilters
bin
Initializers
Properties
Settings.settings
Themes
Test.GridSorting
bin
Debug
Test.GridFilter.vshost.exe
Properties
Settings.settings
using System;
using System.ComponentModel;
using System.Windows;

namespace Stepi.UIFilters
{
    /// <summary>
    /// Defines the class used by the multi filter view.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class UIFilterValueItem<T> :   IUIFilterValueItem<T>
    {
        private readonly static PropertyChangedEventArgs _selectedChangedArgs = new PropertyChangedEventArgs("IsSelected");

        //private static readonly DependencyProperty IsSelectedProperty;

        //static UIFilterValueItem()
        //{
        //    IsSelectedProperty = DependencyProperty.Register("IsSelected", typeof(bool), typeof(UIFilterValueItem<T>), new PropertyMetadata(false));
        //}

        /// <summary>
        /// the value is selected
        /// </summary>
        private bool _isSelected ;

        /// <summary>
        /// instance of the value
        /// </summary>
        private readonly T _value;

        public event PropertyChangedEventHandler PropertyChanged = delegate { };

        /// <summary>
        /// Initializes a new instance of the <see cref="UIFilterValueItem&lt;T&gt;"/> class.
        /// </summary>
        /// <param name="value">The value.</param>
        public UIFilterValueItem(T value)
        {
            _value = value;
        }

        /// <summary>
        /// Gets or sets a value indicating whether this instance is selected.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this instance is selected; otherwise, <c>false</c>.
        /// </value>
        public bool IsSelected
        {
            get
            {
                return _isSelected;
                //return (bool) GetValue(IsSelectedProperty);
            }
            set
            {
                //SetValue(IsSelectedProperty, value);
                if (_isSelected != value)
                {
                    _isSelected = value;
                    PropertyChanged(this, _selectedChangedArgs);
                }
            }
        }

        /// <summary>
        /// Gets the value held by this class.
        /// </summary>
        /// <value>The value.</value>
        public T Value
        {
            get
            {
                return _value;
            }
        }


        /// <summary>
        /// Gets the value.
        /// </summary>
        /// <value>The value.</value>
        object IUIFilterValueItem.Value
        {
            get { return Value; }
        }

    }
}

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 Eclipse Public License 1.0

Share

About the Author

Stefan Bocutiu
Software Developer (Senior) Lab49
United Kingdom United Kingdom
No Biography provided

| Advertise | Privacy | Mobile
Web03 | 2.8.140926.1 | Last Updated 29 Jan 2009
Article Copyright 2009 by Stefan Bocutiu
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid