Linking View to Model through the Controller
With the menu definition data structure (the model), the MenuController (the controller), and the interfaces defining the menu objects (the view) all the components are in place to implement the Model-View-Controller pattern on the menu system. You just need to create a concrete implementation of the user control by implementing the IWTMenu and IWTMenuItem interfaces.
Although there's not room to build an actual implementation in this article, to whet your appetite, the next article creates a sample set of implementations for a menu control, using the interfaces, including a WTTreeMenu (a menu based on a TreeView), a WTNavTreeMenu (a combination of navigation tabs on first menu level and tree menus starting at the second level) and a Control Panel-like menu. To switch from one menu to another in the sample application you can simply replace one menu component with another one and bind it to the controller’s Menu property.
The downloadable sample application shown in Figure 4 uses the WTNavTreeMenu component, while the one in Figure 5 shows the same application using a WTTreeMenu component.
|Author's Note: You can switch the sample application from one menu type to another. To use the menu shown in Figure 4, set SampleNavTreeMenu.wgx as the redirect page in Index.htm or as the start page in Project Properties → Web → Start Action → Specific Page. To use the menu shown in Figure 5, set SampleTreeMenu.wgx as the redirect page in Index.htm or as the start page in the Project properties.|
If you edit the menu configuration file, located in MiniCMS\Resources\Config\ MiniCMSMenu.xml, or add or change images or icons, you will need to increase the Private Version setting in web.config or in the Project properties → General tab, as shown in Figure 6. This is necessary to invalidate the cache and reload any content files from the server (such as new configurations, images, icons, reports, etc.)
Feel free to experiment with the sample menuing system. The next article approaches menus from the standpoint of building custom menus that work with the menuing framework you've seen described here.