我遇到了WpfDataGrid
问题。 我创建了一个控制,该控制打开一个窗口wpf datagrid不可编辑
var wb = new DataEntry(b, Connectionstring);
wb.Show();
窗口DataEntry
包含TextBox
和DataGrid
其示出了作为不可编辑。
,我读了建议插入一个帖子:我试过了,现在TextBox
运作良好,但DataGrid
仍然是不可编辑
ElementHost.EnableModelessKeyboardInterop(wb);
前wb.Show();
。
谢谢支持。
我补充一点,我使用
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;
.... 白衣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");
在XAML我插入
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>
因此,我希望当Windows初始化数据网格具有1行可编辑的,但数据网格不存在此行,我不能添加其他行
你的问题是什么?你想让'DataGrid'可编辑吗?你有什么尝试?文档是否支持编辑? – 2013-02-16 11:41:56
开头我编写此代码 WB =新的DataEntry(B,的connectionString); ElementHost.EnableModelessKeyboardInterop(WB); wb.Show(); 在一个窗口的形式和它的作品。但这只是一个考验。 对于发行版,我需要将其插入到一个WPF窗口,当我做到这一点的数据网格变得不可编辑 – user2078205 2013-02-16 11:48:02