how to get datagrid's selectedItems in MVP Patterns

Apr 9, 2010 at 2:08 AM

I want to publish events in PresentationModel when the datagrid's selection is changed. So I cann't use the datagrid's selectionchanged event.                 

so, I do the following things:

xaml:

 <dg:DataGrid x:Name="dgrid" ItemsSource="{Binding Path=GridData}" SelectedIndex="{Binding Path=SelectedIndex}"
 IsSynchronizedWithCurrentItem="True"/>

 PresentationModel.cs:

        bool _isSelected = true;
        public bool IsSelected
        {
            get { return _isSelected; }
            set 
            {
                if (_isSelected != value)
                {
                    _isSelected = value;
                    OnPropertyChanged("IsSelected");
                    if (value)
                    {

                       DataGridSelectedEvent e1 = this._eventAggregator.GetEvent<DataGridSelectedEvent>();
                        e1.Publish(......);
                    }
                }
            }
        }
so I can get the message in PresentationModel when the datagrid selection changed, but the selectionItems 
which received through View interface are always the last selectionItems, not the current ones.That is to say,
when the SelectedIndex changes,  I publish event before the selectionItems update. how can i do with this situation?
Question: I want publish a selectionchanged even in my PresentationModel, so I need to know when the datagrid selectionchanged, 
and get the current selectionItems in my PresentationModel. how can I do?
shura