I'm still fairly new to WPF, but learning. I have a new application which needs to display values of many data items, potentially hundreds. Since each item is of a particular type (integer, boolean, single), I have an XML settings file to describe behaviors for each item prior to displaying.
I Got the bright idea of using XmlBinding for the controls. I can store current value in each XML node, and bind that to the appropriate control in my XAML. In theory this works fine. I can put a button on my window, whose code modifies an XML element's Value attribute, and the appropriate control updates, no problem.
In actual use, however, I have big issues. I can't update the XmlDocument from the thread that collects data. So since I'm using BackgroundWorkers, I call ReportProgress at each data-collection iteration, and in ProgressChanged event, I can update my XML. Seems ok, but can't get it to work.
Right now, the incoming data is in XML format, which exactly matches my working XML document (except for new values). I tried setting my XmlDocument to the incoming XmlDocument, but that messes up my binding. I've tried several things to solve this (see this post), but can't get it working. I tried looping through the 2 XmlDocuments, replacing "my" values with the incoming values. This takes forever. I've even tried ImportNode and ReplaceNode on the pertinent data area, but it also takes a LONG time, specifically the ImportNode method takes 3 minutes the first iteration, then much faster after that. Still unusable.
So, I think I need to give up XmlBinding and go to something else. The project is still in early stages, so this is possible.
Big preamble for the real question: Can someone suggest a simple way to do my data binding? DataSets? DataTables? Lists? Collections? Just need to be able to easily bind the controls in my XAML, and it should be thread-safe so I don't encounter issues updating the GUI (although I could continue to use the ProgressChanged event). I need a data type that automatically notifies bindings to update. I will also need to save the data to a database, so DataSets or DataTables (or something like that...I'm not a big ADO.NET expert) seem logical. But, I don't mind iterating a structure or collection to build my INSERT statement, either. That's what I'm presently doing to get my XML data into the database.
Thanks for any suggestions (and hopefully some XAML/code samples?)...
Ron Mittelman