You have a good example of how to bind to a property inside of a combobox item and link a second combobox to the first combobox item when you posted the following
<Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type igDP:DataRecordPresenter}}, Path=DataRecord.DataItem.State.Cities}" /> <Setter Property="DisplayMemberPath" Value="CityName" /></Style>
This works well, the problem is that I have a very complex heirarchy and need to bind to a list farther up the heirarchy. As an example, I will use the hypothetical data structure
PlanetList: Planet: Country: State: City
How would I change the ancestor type to reference in a list in the correct Planet record from the state combobox. I cant reference the Planet directly because it is part of a list and I need the planet being used to display the state combobox items.
Great solution. This should do it.
Just out of curiosity, will this work if you group by couple of fields and then expand the groupby records?
I figured this out for anyone else that needs to reference farther up the data object chain.
<Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type igDP:DataRecordPresenter}, AncestorLevel=3}, Path=DataRecord.DataItem.ListToUse}" /> <Setter Property="DisplayMemberPath" Value="CityName" /></Style>
Ancestor level will move up one DataRecordPresenter in the hierarchy for each level.
Hello,
I am not completely sure whether this is possible. Maybe you could try an external property (dependency property) which will be synchronized with current planet object, so that you can bind to that.