How I can implement a full dialog box?

Topics: Prism v4 - WPF 4
Jul 28, 2011 at 10:54 PM

Hello.

In my program there are a few data adapters (modules) they have a common interface.

IDataAdapter
{
    	int GetData();
}

But each also has individual settings.

Public Class DataAdapter_1 : IDataAdapter
{
	string Name;
	string Password;
}

Public Class DataAdapter_2 : IDataAdapter
{
	string Name;
	string Password;
	string ConnectionSettings;
}

I would like to make a full dialog box to configure them. Like this http://www.expression-web-tutorials.com/images/new-style-dialog-box.jpg

For example. The user launches the wizard of added of the new data adapter. Prism scans the directory with the modules and displays all found the date adapters, next the user selects the necessary data adapter and opens the window adapter settings for the selected data adapter. How is it possible to implement. Sorry for my bad English.

Developer
Jul 29, 2011 at 6:14 PM

Hi,

Modules are pieces of functionality generally grouped into a project, which define certain views and services that are exported to the rest of the application. Therefore, your data adapters should be services that are consumed within the different components of your application, not modules itself. They should be placed inside modules, and probably the structure of each module should be based on the functionality you intend to expose through these data adapters.

Additionally, modules contain one class that implements IModule, which contains an Initialize method that defines what needs to be done upon the module's initialization (for example, exporting services, registering views into regions, etc.). That class is usually responsible only for the aforementioned, and generally does not contain more logic than that; it rather exports the services and views that contain that specialized logic.

You might find the StockTrader Reference Implementation useful as an example to verify this.

Then, modules can be loaded on demand, so you could mark all the modules you require as OnDemand modules, and browse them in your popup window; then, you could launch the pertinent components of the modules you've decided to load, by calling the ModuleManager's LoadModule method. For the case of discovering modules in a directory, you might find the Discovering Modules in a Directory section of the Modularity Chapter in the Prism MSDN documentation useful.

I hope you find this helpful.

Guido Leandro Maliandi
http://blogs.southworks.net/gmaliandi

Jul 29, 2011 at 8:25 PM

You misunderstood me.

For example. Consider the Stock Trader.

How can I make a few (News modules) each of which is connected to its source (Blomberg, Moody's). Each module has its own settings. 

I would like to

1) Select the module.

2) Set it using the wizard.

The Wizard should be in the form of a modal window.

Or how else can I make the choice and configuration News module.

Developer
Aug 1, 2011 at 3:22 PM

Hi,

If you wish to launch multiple instances of a similar view loaded with different settings based on a configuration, you should take into account that modules are not intended to be instantiated more than once; instead, as I've mentioned in my previous answer, modules should export views and services that can be consumed throughout your application.

Therefore, in order to fulfill your use case, you could have some views (with their respective view models), that probably consume a service you've defined wich exposes information from certain sources; then, you could have your wizard instantiate these views based on the configuration provided.

As they're probably related to the same set of functionality, the aforementioned views could be placed in the same module.

I hope you find this helpful.

Guido Leandro Maliandi
http://blogs.southworks.net/gmaliandi