im exploring the world of WPF, I find a great example on the web on how to use binding in xml
http://www.codeproject.com/Articles/37854/How-to-Perform-WPF-Data-Binding-Using-LINQ-to-XML
Now I'm trying to extend this example: I want to create a “middle class” between the XElement and the user interface and bind all the togheder in the chain, so if I have a modification in xml, then I add the property to the middle class, the updated user interface.
Here is the code:
This is the class that wraps XElement
public class XElementDataProvider : ObjectDataProvider { public XElementDataProvider() { ObjectInstance = XElement.Load(@"C:\MyFile.xml"); } private static XElementDataProvider instance; public static XElementDataProvider Instance { get { if (instance == null) { instance = new XElementDataProvider(); } return instance; } } }
This is MiddleClass
public class MiddleClass : DependencyObject { XElementDataProvider xElementDataProvider; XElement myxml; public MiddleClass() {
A book is a class that represses a book, and for now, let it have only a name.
Invalid user interface class, but must bind to public List<Book> book lists and display book names to the user in the ListBox
Enyone knows why I am not receiving any notification ... or what do I need to do to make the public List<Book> BookList synchronize with the private IEnumerable<XBookList> ?
source share