title: How to bind TextBoxes to an XML File (with namespace)
body: <p>I use C#.
  I want to make a Twoways bind between Textboxes and an XML data source. In order to achieve that, I have written this:</p>
  
  <pre><code>1  Binding source = new Binding();
  2
  3  // object ddd = XmlManager.Instance.CreateAttributeOrElement(XPath);
  4  source.Path =
  5      new PropertyPath(
  6          string.Format("(XmlManager.Instance.CreateAttributeOrElement({0}))", XPath));
  7  source.Mode = BindingMode.TwoWay; 
  8
  9  UIElementos.UiTexto textoCampo = this as UIElementos.UiTexto;
  10 textoCampo.elementoTexto.SetBinding(TextBox.TextProperty, source);
  </code></pre>
  
  <p>Where:</p>
  
  <ul>
  <li><code>XPath = "dummyns/@totalConcept"</code></li>
  <li><code>XmlManager.Instance.CreateAttributeOrElement</code> creates the attribute in the XML Document which the bind will to do to TextBoxes.</li>
  <li>The <code>CreateAttributeOrElement</code> method of the <code>XMLManager</code> object returns some like this:
  <code>totalConcept=""</code></li>
  </ul>
  
  <p>There is a commented line which creates the attribute. The other way is ot make it implicit in the instantiation line of <code>PropertyPath</code>. When either of the ways is executed, it generates an XML Document like this:</p>
  
  <pre><code>&lt;cna:dummyns xmlns:cna=\"http://tempuri.org/XMLSchema.xsd\" totalConcept=\"\" /&gt;
  </code></pre>
  
  <p>But when I assign a value to <code>Textbox</code>, I get this in the Output window:</p>
  
  <pre><code>System.Windows.Data Warning: 78 : BindingExpression (hash=3146959): TransferValue - got raw value {DependencyProperty.UnsetValue}
  System.Windows.Data Warning: 86 : BindingExpression (hash=3146959): TransferValue - using fallback/default value ''
  System.Windows.Data Warning: 87 : BindingExpression (hash=3146959): TransferValue - using final value ''
  </code></pre>
  
  <p>So the Bind is not working... 
  In the line #6, I also tried:</p>
  
  <pre><code>string.Format("XmlManager.Instancia.declaracion.Root.Attribute[\"{0}\"].Value", XPath)
  </code></pre>
  
  <p>But I got the same result.</p>
  
  <p>Has anybody got something similar to this working?</p>
  
  <p>Any comments or suggestions are welcome.</p>