public AddDataGridColumnsUserInterface(EditingContext context, ModelItem dataGrid)
            : this()
        {
            _dataGrid = dataGrid;
            _context  = context;

            _columns = DataGridColumnModelCollection.Create(_dataGrid);
            _dataSourceProperties = DataSourcePropertyModelCollection.Create(_dataGrid);
            _columnTypes          = DataGridColumnTypeModelCollection.Create();

            _dataSourcePropertiesCVS        = new CollectionViewSource();
            _dataSourcePropertiesCVS.Source = _dataSourceProperties;
            _dataSourcePropertiesCVS.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
            _dataSourcePropertiesCVS.Filter       += new FilterEventHandler(_dataSourcePropertiesCVS_Filter);
            dataSourceColumnsListBox.ItemsSource   = _dataSourcePropertiesCVS.View;
            dataSourceColumnsListBox.SelectedIndex = 0;
            dataSourceColumnsListBox.AddHandler(UIElement.MouseDownEvent, new MouseButtonEventHandler(HandleListBoxItemDoubleClick), true);

            datagridColumnsListBox.ItemsSource   = _columns;
            datagridColumnsListBox.SelectedIndex = 0;
            datagridColumnsListBox.AddHandler(UIElement.MouseDownEvent, new MouseButtonEventHandler(HandleListBoxItemDoubleClick), true);

            columnTypeComboBox.ItemsSource   = _columnTypes;
            columnTypeComboBox.SelectedIndex = 0;
        }
        internal static DataGridColumnModelCollection Create(ModelItem dataGrid)
        {
            DataGridColumnModelCollection columns = new DataGridColumnModelCollection(dataGrid);

            columns.Initializing = true;
            try
            {
                foreach (ModelItem dataGridColumn in dataGrid.Properties["Columns"].Collection)
                {
                    columns.Add(dataGridColumn);
                }
            }
            finally
            {
                columns.Initializing = false;
            }

            return(columns);
        }