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 EditDataGridColumnsUserInterface(EditingContext context, DataGridColumnModel dataGridColumnModel, DataSourcePropertyModelCollection dataSourceProperties)
            : this()
        {
            _dataSourceProperties = dataSourceProperties;
            _dataGridColumnModel  = dataGridColumnModel;
            _context = context;

            this.DataContext = dataGridColumnModel;

            bindingComboBox.ItemsSource = _dataSourceProperties;
            clipboardContentBindingComboBox.ItemsSource = _dataSourceProperties;
        }
        internal static DataSourcePropertyModelCollection Create(ModelItem dataGrid)
        {
            DataSourcePropertyModelCollection properties = new DataSourcePropertyModelCollection();

            object dataSource = dataGrid.Properties[ItemsControl.ItemsSourceProperty].ComputedValue;

            if (dataSource != null)
            {
                foreach (PropertyDescriptor pd in System.Windows.Forms.ListBindingHelper.GetListItemProperties(dataSource))
                {
                    properties.Add(new DataSourcePropertyModel {
                        Name = pd.Name, Property = pd
                    });
                }
            }

            return(properties);
        }