Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
275
Master-detail Grids not refreshing
posted

I have two xamDataGrids one with Persons and one with Jobs and I'm using DataContext to bind to ObservableCollections Persons and Jobs (every person has a list with jobs). Here are my bindings:

DataSource="{Binding Path=Persons}"

DataSource="{Binding Path=Persons/Jobs}"

The problem I have is if I select a person in first grid it doesn't show the related jobs in the second grid, not even when using :

IsSynchronizedWithCurrentItem="True" .

 

Any ideas ?

  • 69686
    Suggested Answer
    posted

    In order for the IsSynchronizedWithCurrentItem property to work, you need to use a wrapper around your Persons object that implements ICollectionView.

    This would work if you create a CollectionView from the Persons object like this:

    ObservableCollection<Person> people = new ObservableCollection<Person>();
    CollectionView wrapper = new CollectionView(people);
    layout.DataContext = wrapper;

    Let me know if you have any questions on this.