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
225
Binding Field to lower elements in XML
posted


How do I bind a Field to a lower XPath element that the default? For instance, I have XML with a structure similar to this

<Family>
  <Persons>
    <Person>
      <FirstName>Bob</FirstName>
      <LastName>Smith</LastName>
      <Friends>
        <Friend>
           <FriendName>Ralph</FriendName>
           <FriendAge>22</FriendAge>
        </Friend>
      </Friends>
    </Person
   .etc
   .etc
 </Persons>
</Family>

In the XAML, I have a DataProvider, e.g.
<XmlDataProvider x:Key="FamilyData" XPath="/Family" Source="Family.xml"/>

and a grid bound to it, e.g.
<igDP:XamDataGrid x:Name="_xamDataGrid" DataSource="{Binding Source={StaticResource FamilyData}, XPath=//Person}">

Fields are defined, e.g.
<igDP:Field Name="FirstName" Label="First Name"/>
<igDP:Field Name="LastName" Label="Last Name"/>
<igDP:Field Name="???" Label="Friend"/>

I want the third Field bound to the relative XPath Friends/Friend/FriendName. How do I do this?

Thanks.
Greg

Parents
No Data
Reply
  • 8576
    Offline posted
    Hi Greg -
     
    You should be able to define your third field as an UnboundField rather than as a FieldUnboundField exposes a BindingMode and a BindingPath property that lets you specify the binding details for the field.  If you set the BindingPath appropriately you should be able to display the data from the child element.
     
    Joe
     
Children