I have a business object called Companies which contains a list of Department objects each of which contains list of Employee objects.
On a form I have a combobox to display the companies, combo box to display the departments, and finally a list box to display the employees.
I created a data provider for the companies which the Companies combobox displays. Is it possible, without using event handlers for selection changed, to bind the department combobox with the "Selected" company.Departments and the Employee combobox with the "Selected" department.Employees?
Setup:
1) Put all the combo boxes within some sort of container, like a StackPanel
2) Assign the Companies business object to the DataContext for the StackPanel
Companies combo box:
3) Set ItemsSource to be "{Binding}"
4) Set IsSynchronizedWithCurrentItem to True
5) Set DisplayMemberPath to be property of Company to display (name of company?)
Departments combo box:
6) Set ItemsSource to be "{Binding}"
7) Set IsSynchronizedWithCurrentItem to True
8) Set DisplayMemberPath to be property of Department to display (name of department?)
9) Finally, to hook the selected selection from the Companies combo box up to the Departments combo box, we will use data binding. This will look something like the following:
Bookmarks