Application crashes when I click on filter of any column in datagrid.

Aug 24, 2012 at 1:52 PM
Edited Aug 24, 2012 at 1:59 PM

 Hi,
 I am using the your dll 'ExtendedGrid'. Its a plain binding that i am using, when I launch the application i can see the data, but when i click on any of the column for filter then it crashses. Can you tell me if I am missing something here?
I am running my project on .Net 4.0.

I have pasted my code below

 

 

 

<Window x:Class="WpfDataGridFilterGroup.Window1"
 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:ExtendedGridControl="clr-namespace:ExtendedGrid.ExtendedGridControl;assembly=ExtendedGrid"
        xmlns:ExtendedColumn="clr-namespace:ExtendedGrid.ExtendedColumn;assembly=ExtendedGrid"
    Title="Window1" Height="300" Width="300">
    <ExtendedGridControl:ExtendedDataGrid ItemsSource="{Binding}" Name="datagrid" AutoGenerateColumns="False" >
        <DataGrid.Columns>
            <ExtendedColumn:ExtendedDataGridTextColumn Header="Age" AllowAutoFilter="True"
                                           Binding="{Binding Age}" />
            <ExtendedColumn:ExtendedDataGridTextColumn Header="Gender" AllowAutoFilter="True"
                                           Binding="{Binding Gender}" />
            <ExtendedColumn:ExtendedDataGridTextColumn Header="Name"
                                           Binding="{Binding Name}" AllowAutoFilter="True"/>
            <ExtendedColumn:ExtendedDataGridTextColumn Header="SecNumber"
                                           Binding="{Binding SecNumber}" AllowAutoFilter="True"
                                           CanUserSort="False" Width="*"/>

        </DataGrid.Columns>
    </ExtendedGridControl:ExtendedDataGrid>

</Window>

using System.Windows;
using System.ComponentModel;
using System.Windows.Data;
using System.Collections;
namespace WpfDataGridFilterGroup
{

    /// <summary>
    /// /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {

        People people = null;
        public Window1()
        {

            InitializeComponent();

            datagrid.ItemsSource = new People();

        }       
    }
    

    //data source

    public class Person
    {

        public int Age { get; set; }

        public string Gender { get; set; }

        public string Name { get; set; }

        public string SecNumber { get; set; }

    }

    //add a bunch of Person to a collection

    public class People : System.Collections.ObjectModel.ObservableCollection<Person>
    {

        public People()
        {

            for (int i = 1; i < 10; i++)
            {

                if (i < 5)
                {
                    this.Add(new Person() { Age = i, Gender = "Female", Name = "Name" + i, SecNumber = "SecNumber" + i });
                }

                else if (i < 8)
                {
                    this.Add(new Person() { Age = i, Gender = "Male", Name = "Name" + i, SecNumber = "SecNumber" + i });

                }

                else this.Add(new Person() { Age = i, Gender = "Female", Name = "Name" + i, SecNumber = "SecNumber" + i });

            }

        }

    }

}