I can assure you: SelectedItems is indeed bindable as a XAML commandparameter
After a lot of digging and Googling, I has finally found a simple solution to this common issue.
Must follow all the following rules:
-
Following Ed Ball's suggestion ', on you XAML command databinding, define CommandParameter p Roperty before Command property. This a very time-consuming bug.
-
Make sure your ICommand ' s canexecute and Execute methods has a parameter of object type. This is the can prevent silenced cast exceptions that occurs whenever databinding Commandparameter type does not match your command method ' s parameter type.
Private bool Ondeleteselecteditemscanexecute (object SelectedItems)
{
//Your goes heres
pre> }
Private bool Ondeleteselecteditemsexecute (object SelectedItems)
{
//Your goes here S
}
For example, you can either send a Listview/listbox ' s selecteditems the property to you ICommand methods or The Listview/listbox it self. Great, isn ' t it?
Hope It prevents someone spending the huge amount of time I did to figure out how to receiveSelectedItems as CanExecute parameter.
WPF Datagrid multiple SelectedItems in MVVM