TreeGridCell CreateCell(TreeGridColumn column)
        {
            TreeGridCell cc;

            if (this.OwnerRow.IsHeaderRow)
            {
                cc = new TreeGridHeaderCell { Column = column, OwnerRow = this.OwnerRow };
                cc.DataContext = column;
                cc.SetBinding(TreeGridCell.ContentTemplateProperty, new Binding { Source = column, Path = new PropertyPath(TreeGridColumn.HeaderTemplateProperty) });
                cc.SetBinding(TreeGridCell.ContentProperty, new Binding { Source = column, Path = new PropertyPath(TreeGridColumn.HeaderProperty) });
                cc.SetBinding(TreeGridHeaderCell.ContextMenuProperty, new Binding { Source = column, Path = new PropertyPath(TreeGridColumn.ContextMenuProperty) });
                cc.Loaded += OnHeaderCellLoaded;
            }
            else
            {
                cc = new TreeGridCell { Column = column, OwnerRow = this.OwnerRow };
                cc.SetBinding(TreeGridCell.DataContextProperty, rowDataBinding);
                cc.SetBinding(TreeGridCell.ContentProperty, column.CellBinding ?? this.rowDataBinding);
                cc.SetBinding(TreeGridCell.ContentTemplateProperty, new Binding { Source = column, Path = new PropertyPath(TreeGridColumn.CellTemplateProperty) });
                column.PropertyChanged += OnColumnPropertyChanged;
            }

            this.Children.Add(cc);
            return cc;
        }
        TreeGridCell CreateCell(TreeGridColumn column)
        {
            TreeGridCell cc;

            if (this.OwnerRow.IsHeaderRow)
            {
                cc = new TreeGridHeaderCell {
                    Column = column, OwnerRow = this.OwnerRow
                };
                cc.DataContext = column;
                cc.SetBinding(TreeGridCell.ContentTemplateProperty, new Binding {
                    Source = column, Path = new PropertyPath(TreeGridColumn.HeaderTemplateProperty)
                });
                cc.SetBinding(TreeGridCell.ContentProperty, new Binding {
                    Source = column, Path = new PropertyPath(TreeGridColumn.HeaderProperty)
                });
                cc.SetBinding(TreeGridHeaderCell.ContextMenuProperty, new Binding {
                    Source = column, Path = new PropertyPath(TreeGridColumn.ContextMenuProperty)
                });
                cc.Loaded += OnHeaderCellLoaded;
            }
            else
            {
                cc = new TreeGridCell {
                    Column = column, OwnerRow = this.OwnerRow
                };
                cc.SetBinding(TreeGridCell.DataContextProperty, rowDataBinding);
                cc.SetBinding(TreeGridCell.ContentProperty, column.CellBinding ?? this.rowDataBinding);
                cc.SetBinding(TreeGridCell.ContentTemplateProperty, new Binding {
                    Source = column, Path = new PropertyPath(TreeGridColumn.CellTemplateProperty)
                });
                column.PropertyChanged += OnColumnPropertyChanged;
            }

            this.Children.Add(cc);
            return(cc);
        }