S
S
simply_user2016-08-03 11:58:11
WPF
simply_user, 2016-08-03 11:58:11

How to connect to a control a data source located in an instance of a class, which in turn is in an ObservableCollection?

Hello!
I am developing a program in which the user can connect to a specific client (the same program) on a local network or via the Internet and upload his files or download existing ones. The list of clients is displayed using the ListBox. In the program, it looks like this: in the MainViewModel there is a collection of ObservableCollection of elements of type RemoteClientViewModel bound to the ListBox. The RemoteClientViewModel is in turn the ViewModel for the RemoteClient model class . View in this case is an element of the ListBox. The window also has a ListView for displaying a list of remote client files. And in RemoteClientViewModel classin theory, there should be a collection with information about these files: size, type, modification date, and so on.
The question is how to connect this collection to the ListView element? Provided that this collection itself will be located in an instance of the RemoteClientViewModel class . And he, in turn, is in the collection, which is the data source for the ListBox and is located in the MainViewModel . In addition, I need to display a list of files corresponding to this client (that is, the ViewModel that is connected to this element) when clicking on a ListBox item in the ListView.
How to do it all? I will be very grateful for your help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Silin, 2016-08-03
@simply_user

If you want to show information for the selected RemoteClient, then you can add the SelectedRemoteClient field to the MainViewModel and bind it to the SelectedItem in the ListBox (which contains the RemoteClient). Well and then to yuzat it in ListView.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question