ListBox cascade

mauede

Well-known member
Joined
Sep 1, 2021
Messages
103
Location
Northwood - UK
Programming Experience
Beginner
I am working with patient data in a hospital.
A patient can have multiple CT scans.
Every CT scan may have several linked structure-sets
Every structure-set contains several structures.

I managed to display a list of structure names directly from a PostgreSQL table.

The next step is to display a list of CT identifiers (strings). Upon selection of a CT identifier I have to display the names of the linked struture-sets and allow the user to select a structure-set. This latter selection will trigger the display of the structure names contained in the selected structure-set.

I am thinking of three ListBoxes. The fist one should contain the CT identifiers. I can implement this step by myself.
My problem is to implement the code that pops up another ListBox, when an item of the fist ListBox is selected, displaying the structure-sets linked to the select CT scan. Here I am in trouble with developing the "code-behind" that realizes the ListBoxes cascade.

Can you please guide me?
Thank you in advance
 
Since you are working with WPF, you don't want to do things in the "code-behind" within the view. You want to do things in the view model and the model to successively filter down what gets bound to the view.
 
Since you are working with WPF, you don't want to do things in the "code-behind" within the view. You want to do things in the view model and the model to successively filter down what gets bound to the view.
I watched a video deling with MVVM but the author uses Calibur Micro that is nice but it is no more supported so I decided to avoid using it.
I have already implemented my 1st GUI draft placing the design controls in MainWindow.xaml and the c# code in MainWindow.xaml.cs. I have a separated helper method that accessed PostgreSQL , a class to connect and access PostgreSQL, a class that contains a structure fields.
At this point reshuffle all the pieces would be deleterious for me.
 
You don't need Calibur Micro to use MVVM in WPF. WPF designed to use MVVM on by itself.

Anyway, so it looks you want to implement a WPF application following the WinForms approach. I recommend searching for various tutorials about implementing Master-Detail UI or views in WinForms because this is essentially what you are doing. With the master list in the first box, you are wanting to see the details of the selected item in the second listbox. Then recursively, as items are selected in the second listbox, the third listbox populates with details.

In WinForms, the traditional way this is implemented is by listening to the selected item changed events of the respective parent list boxes. Each time a new item is selected, the contents of the child listboxes are updated.
 
Back
Top Bottom