views:

44

answers:

1
<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>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 <LinkType Type="RoleObject"> and <LinkedEssence GUID="5747"/> - in document below there is a full description for it that contains the NAME property i need

  <Essence GUID="5747" Type="Role">
    <Properties>
      <Property Name="Name">
        <value>UKPG-22</value>
      </Property>
      <Property Name="TagPrefix">
        <value>UKPG22</value>
      </Property>
      <Property Name="useParentTagPrefix">
        <value>0</value>
      </Property>
    </Properties>
  </Essence>

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.

A: 

i've solved the problem simply by this

<ComboBox SelectedValuePath="@GUID" SelectedValue="{Binding XPath=/EssenceList/Essence[1]/LinkedEssences/LinkType[3]/LinkedEssence[1]/@GUID}" ItemTemplate="{StaticResource rolelistTemplate}" ItemsSource="{Binding XPath=/EssenceList/Essence[@Type]}" IsSynchronizedWithCurrentItem="True" />

so i just set SelectedValuePath to an attribute and SelectedValue to the field i need to save it)