Composition with Stored Settings

Topics: Prism v4 - WPF 4
Jan 25, 2011 at 11:56 PM

Hi,

I'm new to MEF and Prism and have a question on what approach to take. Actually I'm not really sure whether this is a MEF or a Prism problem so I'll pose it to both groups.

I want to make a widget based application that enables users to select widgets that show up on a dashboard screen. Now, let's suppose that the dashboard screen can have a number of different layouts (e.g. single column, two columns, equal split, 60/40 split, etc...). This struck me as a good problem for Prism and MEF. I could have plug-ins that implement, say, IDashboardLayout and use MEF to get all of the layouts that are provided by the current catalogs.

What I want to be able to do is somehow store which layout the user has selected, and also which widgets are where in that layout (assume that I have a working settings storage service that is able to persist whatever settings needed, as this is not a storage problem). My real question is, how do I load the correct layout type with the correct settings at the time of composition?

Thanks

Greg

Jan 26, 2011 at 8:10 PM

Hi Greg,

Based on my understanding of your scenario, one possible approach to fulfill this requirement would be to define a region on the shell that is going to load your “layoutViews” depending on user´s settings. Then in the view model associated to the shell view, you could retrieve these settings and inject the view that represents the layout you need. You can find the following thread useful, as a related issue was discussed.

To achieve this, you could make use of Prism Region Navigation (you can read more about in Prism documentation here).

On the other hand, every layout you define would be a View which defines how your widgets will be displayed. Each view model would have to bind the information to localize every widget on the view depending on your configuration.

I hope you find this information useful.

Thanks,

Miguel Bronzovic
http://blogs.southworks.net/mbronzovic