Click here to Skip to main content
15,884,388 members
Articles / Desktop Programming / WPF

Automatic WPF Toolkit DataGrid Filtering

Rate me:
Please Sign up or sign in to vote.
4.91/5 (109 votes)
21 May 2010BSD6 min read 1.4M   23.5K   167  
This article discusses a component that enables automated content filtering for the WPF Toolkit DataGrid.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using Microsoft.Windows.Controls;

namespace DataGridFilterLibrary
{
    public class DataGridComboBoxExtensions
    {
        public static DependencyProperty IsTextFilterProperty =
            DependencyProperty.RegisterAttached("IsTextFilter",
                typeof(bool), typeof(DataGridComboBoxColumn));

        public static bool GetIsTextFilter(DependencyObject target)
        {
            return (bool)target.GetValue(IsTextFilterProperty);
        }

        public static void SetIsTextFilter(DependencyObject target, bool value)
        {
            target.SetValue(IsTextFilterProperty, value);
        }


        /// <summary>
        ///  if true ComboBox.IsEditable is true and ComboBox.IsReadOnly is false
        ///  otherwise
        ///  ComboBox.IsEditable is false and ComboBox.IsReadOnly is true
        /// </summary>
        public static DependencyProperty UserCanEnterTextProperty =
            DependencyProperty.RegisterAttached("UserCanEnterText",
                typeof(bool), typeof(DataGridComboBoxColumn));

        public static bool GetUserCanEnterText(DependencyObject target)
        {
            return (bool)target.GetValue(UserCanEnterTextProperty);
        }

        public static void SetUserCanEnterText(DependencyObject target, bool value)
        {
            target.SetValue(UserCanEnterTextProperty, 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 BSD License


Written By
Software Developer Fireminds
Croatia Croatia
Sanjin Matusan - C#, WPF, SQL, .NET

Comments and Discussions