MVVM: how to open a lookup window

This forum is meant for questions and discussions about the X# language and tools
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

MVVM: how to open a lookup window

Post by wriedmann »

Hi Nick,

after reading all posts in this thread multiple times and combining it with my needs, I'm now planning the following architecture for my applications (I need modular applications where the modules are coupled together at runtime via configuration files or a configuration database):

The program at startup should create the WorkspaceFactory, a singleton object. That should create then the ShellWindow (a window with only a top menu, a left menu pane and a tabcontrol for the remainder of the canvas).

Then, a module load class loads the needed assemblies, and calls an initialization method for every class in these assemblies that implements a specific interface (this code is already working). This initialization method registers the needed menu entries view/viewmodel couples and checks for the needed database structure, creating and/or modifiying the tables in the database.

I have already such an architecture that works, but without the WorkspaceFactory and withoud messenger. The corresponding view to a viewmodel is found through a datatemplate created at runtime, and the tabcontrol is bound to a collection of viewmodels.

I need such a structure because we do personalized applications and have to integrate the, also with standard modules. In the VO world, every application is a distinct exe file but we need to change that for the next generation of our applications.

Is this structure that can be valid in your opinion or have I to change something?

Thank you very much!

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

MVVM: how to open a lookup window

Post by wriedmann »

Hi Nick,

I would need another clarification to see if I'm right:
The MainViewModel knows it MainView to simplify things. Otherwise it would be complicated that the MainViewModel could add/remove usercontrols to the MainView.
Or is it the following: the WorkSpaceFactory creates a new View/ViewModel couple and adds the view with its ViewModel to the MainView?

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
NickFriend
Posts: 248
Joined: Fri Oct 14, 2016 7:09 am

MVVM: how to open a lookup window

Post by NickFriend »

Hi Wolfgang,

That all sounds sensible to me.... the main thing of course is that it works for you. And as you say, I let the MainViewModel know about the MainView to simplify assigning usercontrols.

Good luck!

Nick
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

MVVM: how to open a lookup window

Post by wriedmann »

Hi Nick,

thank you very much for your answer! I'll try to put things together and let you know.

Wolfgang

P.S. currently I'm on holiday in Mexico, driving around Yucatan, so I have plenty time to think about.
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Post Reply