private void AddColumn(ColumnDefinition columnDefinition, int?index = null)
        {
            var cellTemplate = CreateCellTemplate(columnDefinition);

            DataGridColumn column;

            if (cellTemplate != null)
            {
                column = new DataGridTemplateColumn()
                {
                    ClipboardContentBinding = columnDefinition.CreateBinding("Item.Document."),
                    Header       = columnDefinition.Header,
                    CellTemplate = cellTemplate,
                };
            }
            else
            {
                column = new DataGridTextColumn()
                {
                    Binding     = new Binding("NonExistantProperty"),
                    Header      = columnDefinition,
                    HeaderStyle = InvalidBindingHeaderStyle,
                };
            }

            if (!string.IsNullOrEmpty(columnDefinition.DefaultWidth))
            {
                column.Width = ParseWidth(columnDefinition.DefaultWidth);
            }

            SetAssociatedColumn(column, columnDefinition);

            if (!index.HasValue)
            {
                AssociatedObject.Columns.Add(column);
            }
            else
            {
                AssociatedObject.Columns.Insert(index.Value, column);
            }
        }
 protected override Binding GetBinding(ColumnDefinition definition)
 {
     return(definition.CreateBinding("Item.Document."));
 }