Hi, when using the GridViewSelectColumn filters, it deselects the selecteditems. So I use this bit of code to fix it
private void LoanGrid_OnFiltered(object sender, GridViewFilteredEventArgs e)
{
LoanGrid.SelectedItems.AddRange(SelectedLoans);
}
public BindableCollection<
LoanDTO
> SelectedLoans { get; set; }
private void LoanGrid_OnFiltering(object sender, GridViewFilteringEventArgs e)
{
SelectedLoans = new BindableCollection<
LoanDTO
>();
foreach (var selectedItem in LoanGrid.SelectedItems)
{
SelectedLoans.Add((LoanDTO)selectedItem);
}
}
That works perfectly fine, but I'm trying to have it be in MVVM format using caliburn.
on xaml side, cal:Message.Attach="[Filtered] = [Filtered];[Filtering] = [Filtering] "
ViewModel
private BindableCollection<
LoanDTO
> _oldLoans = new BindableCollection<
LoanDTO
>();
public void Filtered()
{
SelectedLoans = new BindableCollection<
LoanDTO
>(Items.Where(x => _oldLoans.Any(y => y.Id == x.Id)));
}
public void Filtering()
{
_oldLoans = new BindableCollection<
LoanDTO
>();
foreach (var selectedItem in SelectedLoans)
{
_oldLoans.Add(selectedItem);
}
}
The selecteditems get cleared using the MVVM methods. Any thoughts?