Collectionview preventing selectionchange

If you have no needs to keep all the selected listbox items you can just clear the selection.

As an option you can raise PropertyChanged with the null value to clear the current selection.

public Invoice SelectedInvoice
{
    get => _selectedInvoice;
    set
    {
        if (_selectedInvoice != value)
        {
            if (_selectedInvoice != null) // <- add the 'if' block
            {
                _selectedInvoice = null;
                RaisePropertyChanged(() => SelectedInvoice);
            }
            _selectedInvoice = value;
            RaisePropertyChanged(() => SelectedInvoice);
        }
    }
}

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top