Reputation: 7862
I have the following model:
public class Model : INotifyPropertyChanged
{
public ObservableCollection<ViewElement> Elements { get; set; }
public ViewElement CurrentElement { get; set; }
}
And the following grid where the parent DataContext
is the above model:
<dg:XamDataGrid DataSource="{Binding Path=Elements}" />
I want to bind the CurrentElement
property to the Selected Item of the Grid, similar to how I would in a ListView
:
<ListView x:Name="playbackSteps"
ItemsSource="{Binding Path=Elements}"
SelectedItem="{Binding Path=CurrentElement}" />
How would you suggest I do this?
Upvotes: 3
Views: 7025
Reputation: 12256
As stated on the Infragistics forum, the XamDataGrid exposes an IsSynchronizedWithCurrentItem property. To take advantage of this, you need a ListCollectionView of your ObservableCollection. Something like this:
public ListCollectionView ElementsView {get;set;}
// In the constructor:
this.ElementsView = new ListCollectionView(Elements);
Then bind your XamDataGrid to ElementsView.
Upvotes: 4