0

In one project (class library), I have a class that acts as the main engine for my application. Let's call this class "Engine". The "Engine" class contains a public property of type "LocationManager"-- another class in my application. The "LocationManager" class manages a collection of "Network"s-- yes, another class of mine. A "Network" has two public properties: a Guid called "NetworkID" and a string called "Label".

My ultimate goal is to have a visual control (ListView? DataGridView?) in a separate project that binds to the collection of Networks, displaying the Labels and having access to the NetworkIDs. I would like to accomplish this with WinForms and/or WPF.

My problem is that I'm not sure how to set up the data source in my second project. Do I bind to my Engine? If I do, I can only seem to see the LocationManager property, so how would I dig down to the networks within the location manager? How do I ensure that my collection of Networks can be bound to? (ObservableCollection?)

Or do I have to set up a data source specifically for the collection of networks? Does that mean I have to set up a data source in my WinForms project for every collection within my class library project? There will be, literally, about 100. A network manages a collection of facilities. A facility manages a collection of departments. A department manages a collection... Oh, and there are some entities that manage multiple collections. (There's a ProductInstance that has multiple Contracts and multiple Lots and multiple Barcodes.) And at runtime, how will it know which instance of an object to bind to?

Jason
  • 349
  • 3
  • 9
  • Looks like you are mixing models and transformations into a lot of inter-dependencies. If you make your objects models aside from any kind of code that operates on them, it should be simple to dig down to the data you want to bind to (dotted notation). Have you read a few tutorials on MVVM or MVC architecture? It may clear things up. – Ron Beyer Aug 10 '15 at 20:56
  • Agreed with @RonBeyer above. You're asking "what should be the software architecture of my system?" Check out references like: http://www.codeproject.com/Articles/100175/Model-View-ViewModel-MVVM-Explained I prefer WPF, but your choice of UI Platform should be independent of your model architecture. WPF provides some advanced binding facilities to help deal with some of the problems you are describing. – cunningdave Aug 10 '15 at 20:59
  • My goal is specifically to make sure my class library is independent of any GUI that acts on it. The problem is that I have tons of experience in PowerBuilder but zero experience with C#, the .NET framework, and data binding. :( – Jason Aug 10 '15 at 21:01
  • http://stackoverflow.com/questions/1405739/mvvm-tutorial-from-start-to-finish – Ron Beyer Aug 10 '15 at 21:07

0 Answers0