Question Binding DataGidComboBoxColumn to parent information

Sep 8, 2008 at 3:12 PM
Originally posted on the MSDN forums, but they brought me over here, so here's my question:

I have an xml where attributes can reference previously defined properties.  For example, the following is a valid snippet:
<Property name="DataPoint1" /> 
<Property name="DataPoint2" /> 
<Property name="DataPoint3" /> 
<Property name="DataPoint4" /> 
<Property name="DataPoint5" /> 
    <Parameter ref="DataPoint1" /> 
    <Parameter ref="DataPoint2" /> 
    <Parameter ref="DataPoint4" /> 
    <Parameter ref="DataPoint5" /> 

I want to set up a ComboBoxColumn in a datagrid that will query the current data context for valid properties.  This would be perfect (if it were possible):

<tool:DataGrid x:Name="dgParameters" AutoGenerateColumns="False"
                    <CheckBox x:Name="chkSelected" /> 
        <tool:DataGridComboBoxColumn x:Name="dgcReferences" Header="Reference" DataFieldBinding="{Binding XPath=@ref}"  
              ItemsSource="{Binding XPath=../../Property/@name}"/> 

This is invalid because of the following error:

System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element.

In addition, even if that worked, I'm pretty sure the combo box would only be bound once, and this datagrid may be reused to display different sets of xml.