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 (2)
  1. PShaffer says:

    We are struggling with the need to have some control over which implementation of a view to pull in now.  Our application can support several different product-lines.  Each product-line module will provide it’s own implementation of a specific view.  We need to be able to control which one is picked up depending on context elsewhere in the application shell.

  2. erwinvandervalk says:

    Hi PShaffer,

    Could you elaborate on that example a bit?

    If you build your shell very generic, it shouldn’t know that much about the modules offered. But if you want some logic in your shell to determine which modules to show, you need at least some information on your modules to make that decision.

    I’m speculating a bit here, but do you mean something like this?:

    I could imagine your modules also export some information about which productline a specific view belongs to (ie, via an attribute on the views or something). Then you could have some logic in the shell that knows (on a generic level) about product lines. If you select a specific product line somewhere , then you can filter the views you are showing based on the selected product line.

    Is this the scenario you are describing?



Comments are closed.

Skip to main content