locked
Data Bind XML to a combobox RRS feed

  • Question

  • I am trying to use an XML list of states to populate a combobox. In many of the examples that I see they say that you use an XmlDataProvider like this

    <XmlDataProvider x:Key="RssFeed" Source="z:\adoguy.RSS" />

    1. Where in the code do you put this?
    2. When I try to build this string in VS2010 I enter the x: but intellisense doesnt have an option for "Key", only Field Modifier, Name and Uid. I can't find any good examples for what I thought would be a relatively simple task.

    Does anyone know of a step by step tutorial on how this is done?

    Thanks in advance...

     

    • Moved by edhickey Wednesday, June 9, 2010 7:07 PM (From:.NET 3.0/3.5 Windows Workflow Foundation)
    Tuesday, June 8, 2010 6:12 PM

Answers

  • This was moved out of the .NET forum.

    I can move it into a specific forum if you'd like.

    This is regarding your code:

    <XmlDataProvider x:Key="RssFeed" Source="z:\adoguy.RSS" />
    
    
    

     

    Thanks!
    Ed Price a.k.a User Ed, Microsoft Experience Program Manager (Blog, Twitter, Wiki)
    Thursday, December 22, 2011 2:25 PM

All replies

  • xmal code
    
    <Window x:Class="dataBind.Window2"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window2" Height="392" Width="413">
      <Grid DataContext="{Binding}">
        <Grid.RowDefinitions>
          <RowDefinition Height="123*" />
          <RowDefinition Height="230*" />
        </Grid.RowDefinitions>
        <Grid.Resources>
          <XmlDataProvider x:Key="statelist" Source="States.xml" XPath="States//statename"></XmlDataProvider>
        </Grid.Resources>
        <ComboBox Height="23" Width="100
             " ItemsSource="{Binding Source={StaticResource statelist},XPath=//statename}" 
             Margin="146,42,146,165" 
             Grid.Row="1">
          
        </ComboBox>
      </Grid>
    </Window>
    
    XML Format
    <?xml version="1.0" standalone="yes"?>
    <States>
     <State>
      <stateid>0</stateid>
      <stateabb>Select</stateabb>
      <statename>Select</statename>
     </State>
     <State>
      <stateid>1</stateid>
      <stateabb>AL</stateabb>
      <statename>Alabama         </statename>
     </State>
     <State>
      <stateid>2</stateid>
      <stateabb>AK</stateabb>
      <statename>Alaska          </statename>
     </State>
    • Marked as answer by Dave Parker Saturday, June 12, 2010 2:32 AM
    • Unmarked as answer by Dave Parker Saturday, June 12, 2010 2:33 AM
    Wednesday, June 9, 2010 1:53 AM
  • This was moved out of the .NET forum.

    I can move it into a specific forum if you'd like.

    This is regarding your code:

    <XmlDataProvider x:Key="RssFeed" Source="z:\adoguy.RSS" />
    
    
    

     

    Thanks!
    Ed Price a.k.a User Ed, Microsoft Experience Program Manager (Blog, Twitter, Wiki)
    Thursday, December 22, 2011 2:25 PM