/// <summary>
            ///     Property changed callback for DataContext property
            /// </summary>
            private static void OnDataContextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
            {
                // Selector has a bug regarding DataContext change and SelectedItem property,
                // where if the SelectedItem due to old DataContext is a valid item in ItemsSource
                // but the SelectedItem due to new DataContext is not a valid item in ItemsSource,
                // the SelectedIndex remains that of old context instead of changing to -1.
                // This method is a workaround to that problem, since it is of high impact to DataGrid.
                TextBlockComboBox combo = (TextBlockComboBox)d;
                bool isLocalValue       = (DependencyPropertyHelper.GetValueSource(combo, SelectedItemProperty).BaseValueSource == BaseValueSource.Local);

                if (isLocalValue)
                {
                    // Clear the selection and re-apply the binding.
                    BindingBase binding = BindingOperations.GetBindingBase(combo, SelectedItemProperty);
                    if (binding != null)
                    {
                        combo.ClearValue(SelectedItemProperty);
                        DataGridComboBoxColumn.ApplyBinding(binding, combo, SelectedItemProperty);
                    }
                }
                else
                {
                    // Clear the selection by setting the local value
                    // and re-evaluate the property by clearing the local value.
                    combo.SelectedItem = null;
                    combo.ClearValue(SelectedItemProperty);
                }
            }
        PactComboBox pcb = null;//= new PactComboBox() { FeatureID=1 };
        /// <summary>
        ///     Creates the visual tree for text based cells.
        /// </summary>
        protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
        {
            //if (pcb == null)
            pcb = new PactComboBox()
            {
                FeatureID = this.FeatureID
            };


            //   SyncProperties(pcb);

            //ApplyStyle(/* isEditing = */ true, /* defaultToElementStyle = */ false, textBox);
            ApplyBinding(pcb, PactComboBox.TextProperty);
            DataGridComboBoxColumn.ApplyBinding(SelectedValueBinding, pcb, PactComboBox.SelectedValueProperty);
            pcb.SelectedValue = ((System.Data.DataRowView)(cell.RowDataItem)).Row[((System.Windows.Data.Binding)(SelectedValueBinding)).Path.Path].ToString();

            if (pcb.SelectedValue.ToString().Length == 0)
            {
                pcb.SelectedValue = null;
            }
            return(pcb);
        }