using System.Windows.Controls;
using Telerik.Windows.Controls;
using Telerik.Windows.Data;
using Telerik.Windows.Controls.GridView;

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

            // Get only players with a number less than 10
            ColumnFilterDescriptor numberColumnFilter = 
                new ColumnFilterDescriptor((IDataFieldDescriptor)this.playersGrid.Columns[1]);
            numberColumnFilter.FieldFilter.Filter1.Operator = FilterOperator.IsLessThan;
            numberColumnFilter.FieldFilter.Filter1.Value = 10;
            this.playersGrid.FilterDescriptors.Add(numberColumnFilter);

            // Get only players from England and Spain
            ColumnFilterDescriptor countryColumnFilter = 
                new ColumnFilterDescriptor((IDataFieldDescriptor)this.playersGrid.Columns[2]);
            countryColumnFilter.DistinctFilter.DistinctValues.Add("England");
            countryColumnFilter.DistinctFilter.DistinctValues.Add("Spain");
            this.playersGrid.FilterDescriptors.Add(countryColumnFilter);

            this.playersGrid.ItemsSource = Club.GetPlayers();
        }
    }
}