我遇到了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