ورود

View Full Version : سوال: حذف سطر انتخاب شده دیتاگرید



water_lily_2012
پنج شنبه 28 مهر 1390, 17:29 عصر
سلام
فکر کنم عنوان سوال کافی باشه.

niloo17
شنبه 30 مهر 1390, 10:12 صبح
سلام
توي فايل xaml


<Button Command="{Binding DeleteCommand}">

و در viewmodel


private RelayCommand _DeleteCommand;
public ICommand DeleteCommand
{
get
{
if (_DeleteCommand == null)
_DeleteCommand = new RelayCommand(param => DeleteCommandExecute(param), param => DeleteCommandCanExecute());
return _DeleteCommand;
}
}
public void DeleteCommandExecute(object param)
{
if (CurrentCustomer != null)
{

var del = crm.Customer.Single(e => e.ID == CurrentCustomer.ID);
crm.Customer.DeleteObject(del);
crm.SaveChanges();
var all = from a in crm.Customer
select a;
AllCustomer = new ObservableCollection<Customer>(all.ToList());
OnPropertyChanged("AllCustomer");
}
});
}
}
public bool DeleteCommandCanExecute()
{
return true;
}

water_lily_2012
یک شنبه 01 آبان 1390, 16:26 عصر
سلام
میشه لطف کنید یه توضیح هم درباره این کد بدهید، تا من هم متوجه بشوم.