Hi!
I'm new in PRISM and WPF and sorry for my English too.
My problem is the following:
I have a datagrid, and when the user would like to delete rows, I notify him/her with a Confirmation Popup window (prism). If he/she accept, the selected rows will be deleted, but if he/she cancel the process, after closing this window, the datagrid doesn't get back his focus.
The selected record is only gray and not blue, like in default situation.
This is my ViewModel:
public class DataManipulationViewModel : BindableBase
{
private ObservableCollection<PriceCalcDS.BUTORLAPRow> collectionButorlap;
private ObservableCollection<PriceCalcDS.BUTORLAPRow> currentButorlap;
private ICollectionView colViewButorlap;
private readonly ICommand deleteCommandButorlap;
private Confirmation confirmation;
public InteractionRequest<IConfirmation> ConfirmationRequestDeletingRecords { get; private set; }
public ObservableCollection<PriceCalcDS.BUTORLAPRow> CurrentButorlap
{
get { return currentButorlap; }
set
{
this.SetProperty(ref this.currentButorlap, value);
}
}
public ICollectionView ColViewButorlap
{
get { return colViewButorlap; }
set
{
this.SetProperty(ref this.colViewButorlap, value);
}
}
public ICommand DeleteCommandButorlap
{
get { return deleteCommandButorlap; }
}
public DataManipulationViewModel()
{
DataBase.FillDataSet();
this.collectionButorlap = new ObservableCollection<PriceCalcDS.BUTORLAPRow>();
this.currentButorlap = new ObservableCollection<PriceCalcDS.BUTORLAPRow>();
FillDtButorlap();
this.colViewButorlap = new ListCollectionView(collectionButorlap);
this.colViewButorlap.CurrentChanged += SelectedButorlapChanged;
this.deleteCommandButorlap = new DelegateCommand<object>(this.DeleteRecordButorlap);
this.ConfirmationRequestDeletingRecords = new InteractionRequest<IConfirmation>();
this.confirmation = new Confirmation();
}
private void SelectedButorlapChanged(object sender, EventArgs e)
{
this.currentButorlap.Clear();
if (colViewButorlap.CurrentItem != null)
{
this.currentButorlap.Add(colViewButorlap.CurrentItem as PriceCalcDS.BUTORLAPRow);
}
}
private void FillDtButorlap()
{
foreach (var item in StaticDataSet.priceCalcDs.BUTORLAP.Rows)
{
collectionButorlap.Add(item as PriceCalcDS.BUTORLAPRow);
}
}
private void DeleteRecordButorlap(object parameter)
{
IList selection = (IList)parameter;
List<object> deletingRows = new List<object>();
if (selection.Count != 0)
{
foreach (var selectionValue in selection)
{
deletingRows.Add(selectionValue);
}
this.confirmation.Title = "Figyelmeztetés";
if (deletingRows.Count == 1)
{
this.confirmation.Content = "Biztosan törli a kijelölt rekordot?";
}
else
{
this.confirmation.Content = "Biztosan törli a kijelölt rekordokat?";
}
this.ConfirmationRequestDeletingRecords.Raise(
this.confirmation,
c =>
{
if (c.Confirmed)
{
foreach (var deletingRow in deletingRows)
{
collectionButorlap.Remove(deletingRow as PriceCalcDS.BUTORLAPRow);
}
}
else
{
}
});
}
}
}
Can you help me please, how can I solve this problem?
I'm using MVVM pattern, and would be great, if the solution would be in xaml, or ViewModel.