に問題がありDataGrid
ます。DataGrid
を設定すると、CanUserAddRows
新しい黒い行が下部に配置されますDataGrid
が、新しい行をクリックして別のセルにフォーカスを渡すと、空の場合でも行が作成されるため、これらの行は予期しない動作をします。行が空の場合は、新しいアイテムの作成を避けて動作を変更したいのですが、RowEditEnding
設定した場合e.Cancel=true
、それNewItemPlaceHolder
以降、行が消えて行を追加できなくなります。誰かがこれらの問題の答えを見つけましたか?
protected override void OnRowEditEnding(DataGridRowEditEndingEventArgs e)
{
if ((e.Row.Item as DataRowView).Row.ItemArray[0] == null || (e.Row.Item as DataRowView).Row.ItemArray[0].ToString() == String.Empty)
{
e.Cancel = true;
IEditableCollectionView collection = Items as IEditableCollectionView;
if (collection.IsAddingNew)
{
collection.CancelNew();
}
}
base.OnRowEditEnding(e);
}