in wpf datagrid how to get empty row from above? those. when the user wants to add a new line, it always goes below. But I want him upstairs ... can I do this in XAML?
What about NewItemPlaceholderPosition.AtBeginning ? I don't have sample code, but it seems like this is what you are describing. You can always do what Johan offers and move or sort items in the grid programmatically.
Sample code added by Ray Burns:
var view = CollectionView.GetDefaultCollectionView(EmployeeList) as IEditableCollectionView; if(view!=null) view.NewItemPlaceholderPosition = NewItemPlaceholderPosition.AtBeginning;
Please note that this requires NET Framework 3.5 or higher.
MMVM, , :
var newEmp = new EmployeeViewModel(new EmployeeDto()); EmployeeList.Add(newEmp); EmployeeList.Move(EmployeeList.IndexOf(newEmp), 0);
EmployeeListViewModel ObservableCollection of EmployeeViewModels.
. , XAML....
/Johan
, DataGrid, , ItemsSource. , ObservableCollection. WPF , , .NET 4.0, DataGrid Silverlight 3 .NET 4.0.
, ,
ItemSource.Add(new MyObject());
, :
ItemSource.Insert(0, new MyObject());
DataGrid, NewItemPlaceholder . , ( , ).
, NewItemPlaceholder ? , /., , " " " " - . , , .