I have a ListView that is bound to a collection of view models. The Item template contains a button that is bound to a command on the view model. When I set the property that the ItemsSource of the ListView I call RaiseCanExecuteChanged for each viewmodel.
public BindingList<IVehicleViewModel> Vehicles
{
get { return _vehicles; }
set
{
if(_vehicles == value) return;
_vehicles = value;
OnPropertyChanged("Vehicles");
RaiseCanExecuteChangedEvents();
}
}
Despite the fact that I have verified that true is returned for the CanExecute on all view models the button shows as greyed out. The only thing I have noticed is that if I call RaiseCanExecuteChanged when the listview has already been rendered everything works as expected and if I call it before the listview has been rendered and then scroll through the items they sort themselves out.