AutoGenerateFieldをFalseとしてXamTreeGridに階層データをバインドする場合は、子階層のコレクションを持つプロパティ名をName属性に指定したFieldインスタンスを作成してFieldLayouts.Fieldsコレクションに追加します。

                                                                                                                                                                                                                                                                      

        <igDP:XamTreeGrid  x:Name="xamDataTree1" DataSource="{Binding TreeGridData}">
            <igDP:XamTreeGrid.FieldLayoutSettings>
                <igDP:FieldLayoutSettings AutoGenerateFields="False" />
            </igDP:XamTreeGrid.FieldLayoutSettings>
            <igDP:XamTreeGrid.FieldLayouts>
                <igDP:FieldLayout>
                    <igDP:FieldLayout.Fields>
                        <igDP:TextField Name="Name" Label="Name" />
                        <igDP:NumericField Name="FileSize" Label="Size" />
                        <igDP:DateTimeField Name="DateModified" Label="Date" />
                        <igDP:Field Name="Children" />
                    </igDP:FieldLayout.Fields>
                </igDP:FieldLayout>
            </igDP:XamTreeGrid.FieldLayouts>
        </igDP:XamTreeGrid>
    public class ViewModel : INotifyPropertyChanged
    {
        public ViewModel()
        {
            m_treeGridData = new ObservableCollection<FileSystemNode>();

            for (int i = 0; i < 10; i++)
            {
                List<FileSystemNode> children = new List<FileSystemNode>();

                for (int j = 0; j < 3; j++)
                {
                    children.Add(new FileSystemNode
                    {
                        ID = j,
                        Name = "Child" + j,
                        FileSize =j,
                        IsFolder = j % 2 == 0 ? true : false,
                        DateCreated = DateTime.Today.AddDays(j),
                        DateModified = DateTime.Today.AddDays(j + 1)
                    });
                }

                m_treeGridData.Add(new FileSystemNode { ID = i,
                    Name = "Test" + i,
                    FileSize = i,
                    IsFolder =i % 2 == 0 ? true : false,
                    DateCreated = DateTime.Today.AddDays(i),
                    DateModified = DateTime.Today.AddDays(i + 1),
                    Children = children
                });
            }
        }

        private ObservableCollection<FileSystemNode> m_treeGridData;
        public ObservableCollection<FileSystemNode> TreeGridData
        {
            get { return m_treeGridData; }
            set
            {
                m_treeGridData = value;
                NotifyPropertyChanged("TreeGridData");
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged(String info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }
    }

    public class FileSystemNode
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public int FileSize { get; set; }
        public bool IsFolder { get; set; }
        public DateTime DateCreated { get; set; }
        public DateTime DateModified { get; set; }
        public List<FileSystemNode> Children { get; set; }
    }

Tagged:

製品について

Ultimate UI for WPF