title: Binding XML in Silverlight without nominal classes
body: <p>Let's say I have a simple chunck of XML:-</p>
  
  <pre><code>&lt;root&gt;
     &lt;item forename="Fred" surname="Flintstone" /&gt;
     &lt;item forename="Barney" surname="Rubble" /&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>Having fetched this XML in Silverlight I would like to bind it with <a href="http://en.wikipedia.org/wiki/Extensible_Application_Markup_Language" rel="nofollow noreferrer">XAML</a> of this ilke:-</p>
  
  <pre><code>&lt;ListBox x:Name="ItemList" Style="{StaticResource Items}"&gt;
      &lt;ListBox.ItemTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;StackPanel Orientation="Horizontal"&gt;           
                  &lt;TextBox Text="{Binding Forename}" /&gt;
                  &lt;TextBox Text="{Binding Surname}" /&gt;  
              &lt;/StackPanel&gt;
          &lt;/DataTemplate&gt;
      &lt;/ListBox.ItemTemplate&gt;
  &lt;/ListBox&gt; 
  </code></pre>
  
  <p>Now I can bind simply enough with LINQ to XML and a nominal class:-</p>
  
  <pre><code>public class Person {
       public string Forename {get; set;} 
       public string Surname {get; set;}
  }
  </code></pre>
  
  <p>Can it be done without this class?</p>
  
  <p>In other words, coupling between the Silverlight code and the input XML is limited to the XAML only, other source code is agnostic to the set of attributes on the item element.</p>
  
  <p><strong>Edit</strong>:  The use of XSD is suggested but ultimately it amounts the same thing.  XSD->Generated class.</p>
  
  <p><strong>Edit</strong>: An anonymous class doesn't work, Silverlight can't bind them.</p>
  
  <p><strong>Edit</strong>: This needs to be two way, the user needs to be able to edit the values and these values end up in the XML.  (Changed original TextBlock to TextBox in sample above.)</p>