I have an application with a main window that loads in text file(s) and processes them. Once the processing is done, it creates a list of network switch objects. I can then perform various checks and queries on the data. These checks or queries use child windows. I have been passing the list of switches – here’s an example of a child window where I modified the constructor to take my list of switches. I am wondering if this is a bad design or if there is a way to link the child window to the data in the list without having to pass it in. The next major step in this project is going to be a GUI front-end to browse all the data I am parsing out, rather than just run reports. So I want to learn to do it the right way now.
public partial class LogFileWindow : Window
{
private ObservableCollection<LogFileEntry> _LogFileCollection = new ObservableCollection<LogFileEntry>();
private List<CiscoSwitch> SwitchList = new List<CiscoSwitch>();
// constructor modified to accept a list as a paramter
public LogFileWindow(List<CiscoSwitch> sl)
{
SwitchList = sl;
InitializeComponent();
}
…..
}
Just have a look at the wpf MVVM model, like Kent already mentioned. A very good starting point is this post on MSDN:
http://social.msdn.microsoft.com/Forums/pl/wpf/thread/b8922be3-e73c-4d90-9bc6-172421fb6b1c
Greetings,