5
私はC#を使用します。 テキストボックスとXMLデータソースの間にTwowaysバインドを作成したいと思います。それを達成するために、私はこれを書いている:テキストボックスをXMLファイルにバインドする方法(ネームスペースを使用)
XPath = "dummyns/@totalConcept"
XmlManager.Instance.CreateAttributeOrElement
はバインドがテキストボックスに行うにはなりますXML文書内の属性を作成します。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);
を。
totalConcept=""
属性を作成するコメント行があります:
XMLManager
オブジェクトのCreateAttributeOrElement
方法は、このようないくつかを返します。もう1つの方法は、PropertyPath
のインスタンス化行に暗黙的に指定することです。いずれかの方法を実行すると、それはこのようなXML文書を生成します。 <cna:dummyns xmlns:cna=\"http://tempuri.org/XMLSchema.xsd\" totalConcept=\"\" />
しかし、私はTextbox
に値を割り当てるときに、私は、出力ウィンドウにこれを取得する:
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 ''
のでバインドライン#6で... が動作していない、私も試してみました:
string.Format("XmlManager.Instancia.declaracion.Root.Attribute[\"{0}\"].Value", XPath)
しかし、私は同じ結果を得ました。
誰かがこの作業に似た何かを持っていますか?
コメントや提案は大歓迎です。
Pathプロパティの代わりにXPathプロパティを使用してみましたか? [MSDN](http://msdn.microsoft.com/en-us/library/ms742451.aspx)から: "XMLデータソースへのバインド用の真のXPath式はパス値として使用されず、代わりに使用する必要があります相互に排他的なXPathプロパティ " –