我有一个问题WpfDataGrid。我创建了一个控件,这个控件打开一个窗口
var wb = new DataEntry(b, Connectionstring);
wb.Show();
该窗口DataEntry包含TextBox和DataGrid显示为不可编辑的一个。
我读了一篇建议插入的帖子:
ElementHost.EnableModelessKeyboardInterop(wb);前wb.Show();
我试过了,现在TextBox运行良好,但DataGrid仍然不可编辑。
谢谢你的支持。
我添加了我使用的代码
DataEntry class 
private ObservableCollection<RigaBarcode> _righeBarcode = new ObservableCollection<RigaBarcode>();
//so I create the customer object
  private class RigaBarcode : INotifyPropertyChanged 
        {
            public RigaBarcode(string barcode, string coordinate)
            {
                Barcode = barcode;
                Coordinate = coordinate;
            }
            private string _barcode;
            private string _coordinate;         
.... whit setter 和 getter
 public event PropertyChangedEventHandler PropertyChanged;
            protected virtual void OnPropertyChanged(string propertyName)
            {
                PropertyChangedEventHandler handler = PropertyChanged;
                if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
            }
我在这个集合中添加和元素
_righeBarcode.Add(new RigaBarcode("1", "2");
在我插入的xml中
DataGrid ItemsSource="{Binding .}" Name="Fustelle" Margin="10,23,10,10" Grid.Row="8" Grid.ColumnSpan="2" IsReadOnly="False" AutoGenerateColumns="False">
            DataGrid.Columns>
                    DataGridTextColumn  Header="BarCode" Width="90" Binding="{Binding Barcode}"/>
                    DataGridTextColumn  Header="Posizione" Width="90" Binding="{Binding Coordinate}"/>
                /DataGrid.Columns>
            /DataGrid>
所以我希望在初始化窗口时,datagrid 有 1 行可编辑,但 datagrid 不显示这一行,我无法添加其他行