?
Solved

How do I bind a combobox to an XML item attribute

Posted on 2010-08-31
3
Medium Priority
?
657 Views
Last Modified: 2013-11-12
Here is the XML:
<?xml version="1.0" encoding="utf-8" ?>
<states>
      <state name="ALABAMA" abbreviation="AL" />
      <state name="ALASKA" abbreviation="AK" />
...

In my page resource section I have:
<Page.Resources>
        <XmlDataProvider x:Key="StateData" Source="xmlData\states.xml" XPath="states/state" />
...

My control looks like this:
<ComboBox Name="cbxState" ItemsSource="{Binding Source={StaticResource StateData}}"  />

I can see that my combobox is being filled with all the states, but I can't seem to get it to bind to the name attribute.  So my question is how do I get the combobox to list the name attributes associated with the states?

Thank you for your help.
0
Comment
Question by:sbooth1117
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 20

Expert Comment

by:alainbryden
ID: 33570805
Have you not tried

<ComboBox Name="cbxState" ItemsSource="{Binding Source={StaticResource StateData}, Path=name}"  />

?
0
 

Author Comment

by:sbooth1117
ID: 33571081
I thought that as well. I tried again and it still didn't work.
0
 

Accepted Solution

by:
sbooth1117 earned 0 total points
ID: 33572450
DisplayMemberPath="@name" is what worked.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question