Binding Combobox to XML (wpf)

Posted by mortor on Stack Overflow See other posts from Stack Overflow or by mortor
Published on 2010-06-17T06:50:55Z Indexed on 2010/06/17 6:53 UTC
Read the original article Hit count: 187

Filed under:
|
|
|
<EssenceList>
  <Essence GUID="464">
    <Properties>
      <Property Name="Name">
        <value>mt-1232-1. (1-1-3)</value>
      </Property>
    </Properties>
    <Characteristics>
      <Characteristic GUID="78">
        <value>gadget</value>
      </Characteristic>
      <Characteristic GUID="79">
        <value>measures</value>
      </Characteristic>
    </Characteristics>
    <LinkedEssences>
      <LinkType Type="ObjGroup">
        <LinkedEssence GUID="369" />
      </LinkType>
      <LinkType Type="ObjGroupProp" />
      <LinkType Type="RoleObject">
            <LinkedEssence GUID="5747"/>
      </LinkType>
    </LinkedEssences>
  </Essence>
...
  <Essence GUID="5747" Type="Role">
    <Properties>
      <Property Name="Name">
        <value>????-22</value>
      </Property>
      <Property Name="ShortName">
        <value>UKPG-22</value>
      </Property>
      <Property Name="TagPrefix">
        <value>UKPG22</value>
      </Property>
      <Property Name="useParentTagPrefix">
        <value>0</value>
      </Property>
    </Properties>
  </Essence>
...
  <Essence GUID="5748" Type="Role">
  </Essence>
...

in example is a xml file with data from database. now i need to bind it to some fields... i use the XMLDataProvider here

    <Grid.DataContext>
        <XmlDataProvider x:Name="dataxml" XPath="EssenceList/Essence" Source="464.xml"/>
    </Grid.DataContext>

and mostof simple texboxes i bind like

<TextBox Text="{Binding XPath=/EssenceList/Essence/LinkedEssences/LinkType[1]/LinkedEssence/@GUID}" />

but now i need to bind a combobox this way: - the first Essence in the document contains LinkedEssences, that contains and - in document below there is a full description for it that contains the NAME property i need

????-22 UKPG22 0

and many other available Essences for this combobox i managed to bind the list of thems to combobox

 <ComboBox ItemTemplate="{StaticResource rolelistTemplate}"  ItemsSource="{Binding XPath=/EssenceList/Essence[@Type]}" />

so it displays it well, but i can't bind it to my LinkedEssences.

© Stack Overflow or respective owner

Related posts about wpf

Related posts about Xml