This project is read-only.

PRISM integration

Mar 22, 2013 at 3:52 PM

first of all, thanks for sharing this! Very well thought. I really appreciate your work and would like to contribute at least some pieces.

I'd like to use your UI concept using Links instead of Content with PRISM. As far as I understand your concepts from the superficial code scan I performed, I would have to implement region adapters for the ModernMenu, ModernFrame and ModernTab controls. Is there any assumptions/restrictions on your side that I should be aware of when implementing this?
As I have seen in the demo app, you are using hard-coded xaml references for the links. This conflicts with the concept of compiletime-unknown modules and the views contained in the modules. So I think ModernMenu would be the least requiring a custom region adapter. For the other controls, this may be ambivalent. If a module registers its link in the modern menu, there is a high possibility it also knows the content of it and can therefore make it a modern tab or frame. Nevertheless, this is an assumption I make and may not hold in general. So additional region adapters may be necessary.

What do you think?. Anything I missed? I would be happy to contribute the required code.

Mar 22, 2013 at 6:15 PM
Good to hear you want to contribute. I don't have any experience with PRISM. As far as ModernUI is concerned; links are used in menus, lists and tabs and are associated with content that is loaded in a ModernFrame. The actual content load is performed by an implementation of IContentLoader. The default content loader is DefaultContentLoader that simply loads local XAML pages. Replace the default content loader by specifying ModernFrame.ContentLoader. This ContentLoader property is also available on ModernWindow and ModernTab.

Links in the demo app are hard-coded for demonstration purposes only. You can easily replace them with a view model driven collection that is dynamic. The LinkCollection is observable and changes in the collection are applied to the controls.

If you have any further questions or comments be sure to post them here. I'm actively monitoring this discussion list.
Mar 22, 2013 at 6:50 PM
Ok, thanks so far. I'll have a deeper look into it at the weekend. I'll inform you regarding my progress. I will post questions in this thread - ok for you?
Mar 22, 2013 at 7:04 PM
Yep, that's fine. btw; over here another discussion on prism and modernui
Mar 25, 2013 at 10:39 AM
Before I tell you about my current progress, I should give you a small explanation of what I want prism to do, so you have a better idea of what parts I am trying to adapt/map to each other.

Prism has the concept of regions. A region is just a FrameworkElement that is attached a RegionName property from the RegionManager class. This region name can then be used by any other part of the application to inject views into by using a RegionManager.
Since a region can be any FrameworkElement, prism has several so called RegionAdapter classes that actually know how to inject a view into a region of a given type.
A ContentControlAdapter knows how to inject a view into a single-view container (a content control), an ItemsControlAdapter knows how to inject several views into an items control.

When looking at a modern ui app, there are several regions I'd like to be available to my modules. These are the title links, the modern menu as well as the modern tab (since this derives from Control and needs to have its own region adapter, as prism does not provide one ootb).

E.g. I want the configuration module to be able to add its "Settings" link to the "TitleRegion" and some other modules to add their menu/sub menu structure to the "MenuRegion". Whatever the modules register as links, they should be responsible for their content as well. This should be implemented in some IContentLoader, whether generic or provided by a module. From this point, responsibility for the content is at the module level. That's fine.

Now for my observations and ideas:
  1. TitleLinks as well as ModernMenu links are wrapped in the ModernWindow and made available as MenuLinksGroups and TitleLinks. The UI elements representing those are contained in the ModernWindow template and are not accessible. So the FrameworkElement I can use to attach a region name to would be the modern window. Unfortunately, the modern window hosts two regions (TitleRegion and MenuRegion). The title links are really tied to the window chrome, so defining this region on the window seems to be a good idea. If I could access the ModernMenu control from the ModernWindow, I could define the menu region on the menu.
  2. To enable injection of menu items and its content, I would have to implement a region adapter for modern menu. I have several ideas on how to structure this, at the moment I think it would be best to keep the prism region manager work with views and not make it aware of ModernUI-Links (which aren't dependency objects). That's not too bad, since I can think of a view in the MenuRegion as some kind of UI Element (e.g. LoremIpsum) that transports its menu integration via attached properties. I could define an attached behavior called e.g. MenuRegionItem and give it 2 properties called MenuDisplayName and SubMenuDisplayName. I then make any control that wants to integrate in the modern ui MenuRegion have these properties attached, so my custom RegionAdapter knows what links to create in the menu and which content the link points to. I see no other option for arbitrary ui elements transporting this information without implementing code ini the ui elements or derive a set of them (e.g. when using interfaces, attributes, ...). The attached behavior seems my only option here.
I try to come up with a first sample the next days. Afterwards I'll think about where the IContentLoader fits with these ideas. It will definitely be useful, i think.

I also looked at your navigation concepts. These seem very similar to what prism provides. As soon as the region stuff is done, i will see how to marry the navigation concepts.
Apr 4, 2013 at 3:19 AM
Any news about Modern UI Prism Integration/Region Adapters?
I think it doesn't really work well until the Main Menu Parts like TitleMenu and MenuLinkGroups are Properties of ModernWindow instead of external Controls inside the Window.
Apr 4, 2013 at 8:52 AM
Sorry, the discussion has been continued in another thread. Have a look here: Discussion 438029
I posted a demo project there. This was my first approach. I have some ideas for approaching things differently, as the discussion there gives me some other perspectives of thinking about the integration. Would be happy if you also help in finding a nice and clean way to integrate mui with prism.