Example #1
0
        public void RebaseOnSource(DataTemplate rowTemplate, DataTemplate propertyTemplate, DataTemplate columnTemplate)
        {
            int rowCount  = this.Source.Rows.Length;
            int propCount = this.Props.Length;
            int colCount  = this.Source.Columns.Length;

            RowViewModel[]    rows    = new RowViewModel[rowCount];
            ColumnViewModel[] columns = new ColumnViewModel[colCount];
            ItemViewModel[]   items   = new ItemViewModel[rowCount * propCount * colCount];
            int itemIndex             = 0;

            for (int r = 0; r < rowCount; r++)
            {
                RowViewModel row = new RowViewModel(this.Source.Rows[r], rowTemplate, r);
                row.Properties = new RowPropertyViewModel[propCount];

                for (int p = 0; p < propCount; p++)
                {
                    RowPropertyViewModel prop = new RowPropertyViewModel(this.Props[p], propertyTemplate, r, p);
                    row.Properties[p] = prop;
                    for (int c = 0; c < colCount; c++)
                    {
                        items[itemIndex] = new ItemViewModel(c, r, p, itemIndex, this.Source.Rows[r].Items[c], this.Source.Columns[c], this.Props[p], this);
                        itemIndex++;
                    }
                }
                rows[r] = row;
            }
            for (int c = 0; c < colCount; c++)
            {
                columns[c] = new ColumnViewModel(this.Source.Columns[c], columnTemplate, c);
            }

            this.Rows    = rows;
            this.Columns = columns;
            this.Items   = items;
            this._hoverManager.Reset();
        }
        public void RebaseOnSource(DataTemplate rowTemplate, DataTemplate propertyTemplate, DataTemplate columnTemplate)
        {
            int rowCount = this.Source.Rows.Length;
            int propCount = this.Props.Length;
            int colCount = this.Source.Columns.Length;
            RowViewModel[] rows = new RowViewModel[rowCount];
            ColumnViewModel[] columns = new ColumnViewModel[colCount];
            ItemViewModel[] items = new ItemViewModel[rowCount * propCount * colCount];
            int itemIndex = 0;
            for (int r = 0; r < rowCount; r++)
            {
                RowViewModel row = new RowViewModel(this.Source.Rows[r],rowTemplate,r);
                row.Properties = new RowPropertyViewModel[propCount];

                for (int p = 0; p < propCount; p++)
                {
                    RowPropertyViewModel prop = new RowPropertyViewModel(this.Props[p], propertyTemplate,r,p);
                    row.Properties[p] = prop;
                    for (int c = 0; c < colCount; c++)
                    {
                        items[itemIndex] = new ItemViewModel(c, r, p, itemIndex, this.Source.Rows[r].Items[c], this.Source.Columns[c],this.Props[p], this);
                        itemIndex++;
                    }
                }
                rows[r] = row;
            }
            for (int c = 0; c < colCount; c++)
            {
                columns[c] = new ColumnViewModel(this.Source.Columns[c], columnTemplate, c);
            }

            this.Rows = rows;
            this.Columns = columns;
            this.Items = items;
            this._hoverManager.Reset();
        }