using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Telerik.Windows.Controls;
using Telerik.Windows.Data;
using Telerik.Windows.Controls.Filtering.Editors;
using System.Windows.Controls.Primitives;

namespace CustomizedFilteringControl
{
	public partial class MainPage : UserControl
	{
		public MainPage()
		{
			InitializeComponent();

			var playersColumn = (GridViewBoundColumnBase)this.clubsGrid.Columns["PlayersInfo"];
			
			// You can use this in case you want to hide the distinct values list-box since it gets really long.
			playersColumn.ShowDistinctFilters = false;
			
			var customFilteringControl = new CustomizedFilteringControl();
			
			playersColumn.FilteringControl = customFilteringControl;
		}

		private void clubsGrid_FieldFilterEditorCreated(object sender, Telerik.Windows.Controls.GridView.EditorCreatedEventArgs e)
		{
            try
            {
                StringFilterEditor sfe = e.Editor as StringFilterEditor;
                sfe.Loaded += this.OnStringFilterEditorLoaded;
            }
            catch { }
		}

		void OnStringFilterEditorLoaded(object sender, RoutedEventArgs e)
		{
			ToggleButton matchCaseButton = ((StringFilterEditor)sender).ChildrenOfType<ToggleButton>()[0];
			matchCaseButton.IsChecked = true;

			// You can either hide it or disable it. It's up to you.
			//matchCaseButton.Visibility = Visibility.Collapsed;
			matchCaseButton.IsEnabled = false;
		}
	}
}
