Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
25
Grouping in xamDataGrid with Multiple Layouts
posted

I have a xamDataGRid for which I have created two FieldLayout definitions. The Class which gets bound to the grid have some properties and a collection of objects of a different class. The collection is a list which shows up as a child row in the grid.

All that workd fine. My problem is that grouping the fields  using the standard xamDataGrid header does not work, instead of grouping the records it sorts them. Is there something I need to do to make the grouping work in a master/child record layout ?

Below is the XAML and codebehind for a sample app which reroduces the error.

 <Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ig="http://infragistics.com/Windows"
    xmlns:igDP="http://infragistics.com/DataPresenter"
    Title="Window1" Height="300" Width="619">
    <Grid>
        <igDP:XamDataGrid x:Name="xdgTest">
            <igDP:XamDataGrid.FieldLayouts>
                <igDP:FieldLayout Key="PersonalInfo">
                    <igDP:FieldLayout.Fields>
                        <igDP:Field Name="Name" Label="Name"/>
                        <igDP:Field Name="Age" Label="Age"/>
                        <igDP:Field Name="Address" Label="Name"/>
                        <igDP:Field Name="Contacts" Label="Contacts"/>
                    </igDP:FieldLayout.Fields>
                </igDP:FieldLayout>

                <igDP:FieldLayout Key="ContactInfo">
                    <igDP:FieldLayout.Fields>
                        <igDP:Field Label="Contact Type" Name="Type"/>
                        <igDP:Field Label="Contact" Name="Value"/>
                    </igDP:FieldLayout.Fields>
                </igDP:FieldLayout>
            </igDP:XamDataGrid.FieldLayouts>
        </igDP:XamDataGrid>
    </Grid>
</Window>

 namespace WpfApplication1
{
    public class Contact
    {
        public string Type { get; set; }
        public string Value { get; set; }
    }

    public class Person
    {
        public Person(string Nm, int Ag, string Addr, List<Contact> Phones) { Name = Nm; Age = Ag; Address = Addr; Telephones = Phones; }
        public string Name { get; set; }
        public int Age { get; set; }
        public string Address { get; set; }
        public List<Contact> Telephones { get; set; }
    }

    public partial class Window1 : Window
    {
        List<Person> Fields = new List<Person>();

        public Window1()
        {
            InitializeComponent();

            List<Contact> Contacts = new List<Contact>();
            Contacts.Add(new Contact{Value = "5561-6195", Type = "Home"});
            Contacts.Add(new Contact { Value = "3048-6331", Type = "Home" });
            Contacts.Add(new Contact { Value = "9233-9116", Type = "Mobile" });

            Fields.Add(new Person("Thomaz", 38, "Constantino de Sousa 172", Contacts));

            xdgTest.DataSource = Fields;
        }
    }
}