Visual Composition scenario’s
Norman posted a valid question to my previous post on Visual composition styles in Prism V2 drop 4. Can you programmatically influence which view gets pulled into a content control?
In the current bits: No. We might in the near future build something for that, If we can find a clear scenario for when you would use that.
The top down scenario (pull based) is a way to put controls on your view, without having a hard assembly reference to them. The only thing you need to know about your view is the interface. Now if you have more than one view that follows the same interface, you will have to build some kind of controlling logic to determine which view you want to show. This controlling logic needs to know more about the specific views, so it can determine which view to show when. I feel this has much more resemblance to the bottom up push based model.
When to use top down VS bottom up?
In Bottom Up composition, your shell doesn’t know anything about the views it’s displaying. It basically prepares a couple of regions that modules can add their stuff to and that’s it. This is a very open approach that I typically associate with a plug-in model. As an application developer, you don’t know anything about the plug-ins being written, so you provide the means (regions, services, etc) and the plug-ins do the rest.
In Top Down composition, you probably know a lot more about the modules being used. You can specify the specific type of view you want to show (by specifying the interface) but don’t know (or care about) in which assembly or module the view implementation lives. This is a much more closed down approach, but also a lot simpler. If the hosting view knows the interface of the child views it’s displaying, it can interact with them directly.
Mixing them up
I suspect that you might want to mix the top down and bottom up approach. The shell assembly provides a general plug-in model for all top level modules, with a main region and a navigation structure. But within a module, you might compose a view built of several other smaller views. Typically, you are fulfilling a use case here, so you know what kind of functionality you want to call. If you want to use views from other modules there, and you don’t want a static dependency on the implementation of the module, you can use top down composition.
Selecting a specific implementation to display
To come back to the question, can you programmatically control which view is pulled? So you might specify an interface to pull, but there are multiple implementations of that interface registered to the container. We might build an extensibility point where you can plug in your own controller who can select which view to show when. But we’ll probably only build something like this if we can find a good scenario for this solution. Does anybody have the need for this kind of functionality?
Comments
- Anonymous
November 12, 2008
The comment has been removed - Anonymous
November 12, 2008
The comment has been removed