I am attempting to bind a GridViewComboBoxColumn's item source found in a child grid to a property in the data context of the parent row. I believe I need to use a relative source and find an ancestor; however, I am not sure what the ancestor type should be. I was hoping there was something similar to a ListBoxItem type but I have not found one.
Here is my Grid:
Here are my classes:
What I would like to see happen is when the user changes the ParentAttribute (through the Parent Attribute combo box column), the ItemsSource of the Parent Value column in the child grid will be bound to the ParentAttribute.Values field.
Here is my Grid:
<
telerik:RadGridView
Name
=
"ParentGrid"
ItemsSource
=
"{Binding ParentItemSource}"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewComboBoxColumn
Name
=
"Parent Attribute"
></
telerik:GridViewComboBoxColumn
>
</
telerik:RadGridView.Columns
>
<
telerik:RadGridView.ChildTableDefinitions
>
<
telerik:GridViewTableDefinition
/>
</
telerik:RadGridView.ChildTableDefinitions
>
<
telerik:RadGridView.HierarchyChildTemplate
>
<
DataTemplate
>
<
telerik:RadGridView
Name
=
"ChildGrid"
ItemsSource
=
"{Binding Values}"
>
<
telerik:GridViewComboBoxColumn
Name
=
"Parent Value"
ItemsSource
=
"{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ???}}, Path=ParentAttribute.Values}"
></
telerik:GridViewComboBoxColumn
>
</
telerik:RadGridView
>
</
DataTemplate
>
</
telerik:RadGridView.HierarchyChildTemplate
>
</
telerik:RadGridView
>
Here are my classes:
public class MyAttribute
{
public string Name { get; set; }
public MyAttribute ParentAttribute { get; set; }
public ObservableCollection<
MyValue
> Values { get; set; }
}
public class MyValue
{
public string Name { get; set; }
public string Value { get; set; }
}
What I would like to see happen is when the user changes the ParentAttribute (through the Parent Attribute combo box column), the ItemsSource of the Parent Value column in the child grid will be bound to the ParentAttribute.Values field.