xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:ii="http://schemas.microsoft.com/expression/2010/interactivity" <i:Interaction.Triggers> <i:EventTrigger EventName="SelectionChanged"> <i:InvokeCommandAction Command="{Binding SelectedItemsCmd}" CommandParameter="{Binding Path=SelectedItems,ElementName=dg}"/> </i:EventTrigger> </i:Interaction.Triggers>
private ICommand selectedItemsCmd; public ICommand SelectedItemsCmd { get { if(selectedItemsCmd==null) { selectedItemsCmd = new DelegateCommand(SelectedItemsCmdExecuted); } return selectedItemsCmd; } } private void SelectedItemsCmdExecuted(object obj) { System.Collections.IList items = (System.Collections.IList)obj; if(items!=null && items.Count>0) { var collection = items.Cast<SalesOrderDetail>(); SelectedOrders = new ObservableCollection<SalesOrderDetail>(collection); } }