How to bind XmlDataProvider.Source to MVVM property

前端 未结 3 1318
名媛妹妹
名媛妹妹 2020-12-06 23:07

I\'ve got a treeview bound to an XmlDataProvider following this example. The app I am working on is following the MVVM pattern and the Xml is from a file that t

3条回答
  •  不知归路
    2020-12-06 23:46

    I didn't find how to bind the source straight away, but you can change the XmlDataProvider source in the code behind as following:

    var xdp = (XmlDataProvider)this.Resources["key-of-your-XmlDataProvider-in-resources"];
    xdp.Source = new Uri("http://url-of-your-xml");
    

    You can use that combined with an event handler to bind.

提交回复
热议问题