Update 2/26/2011 - A WPF version of this template has been posted. Click here view info and download it..
Update 4/15/2011 - A new forum has been created to ask questions and share ideas about the Silverlight samples on this community. Please click here to visit the forum.
Hello,
If you help with customizing this template to meet your needs or you need a custom application built or started to meet your own specs, please feel free to contact me at kris@n-stech.com or 980-285-7080.
Otherwise the attached code is free so feel free to use how you like. All I ask is you give credit wherever it is used as I have with some of the code in the MVVM.Framework.
Thanks and enjoy.
Attached is a LOB template for creating Silverlight 4 apps using MVVM & Prism 4.0 as well as MVVM Light.
If you aren't familiar with Prism, I strongly suggest you download the Prism 4 help file. It contains good info about Prism as well as MVVM.
Screen shot of what you'll have when you compile the code. (Note this was the first release. Please see image below for what you'll see now.)
SharedAssemblies
All the assemblies used in the solution are in a folder called Shared assemblies. You should just have to add reference paths on each project to the appropriate folder in SharedAssemblies for everything to work.
If you decided to delete the assemblies and readd them, I suggest you set CopyLocal = false except in the main Silverlight app.
Projects
Common
This assembly contains everything that will be shared throughout the application. Items of most importance are the QATBRegionAdapter. This allows us to create a region in the QuickAccessToolBar of the Telerik RibbonBar control.
PopupController - This is what is used to display popup windows. The popup region is defined in the Shell file.
GlobalCommands - Here we define global commands that will be used throughout the application. The base ones allows you to set the Apps template, show the BusyIndicator and log errors.
LogService - Used to define how errors are logged.
RootShellTemplate - Used to define the main layout and regions of the app.
Silverlight_MVVM_Template
ShellViewModel - Contains Properties that controls in our Shell use to set their values. Also, contains a SetAppRootTemplate() function that allows us to set the apps main template. Also it registers for the SetAppIsBusyStatus command and sets the properties contained to the apps global busy indicator contained in shell.
Shell - Contains a BusyIndicator that can be set via a command anywhere in the app. Also, the only other thing Shell contains is a ContentControl which will display the a Template set for the application.
App.xaml.cs - Initializes the BootStrapper which will discuss next. Also, contains a public method which is used to set RootVisual.
Bootstrapper - We override CreateModuleCatalog() to load our modules from the ModulesCatalog.xaml file. We also override CreateContainer() because we need to resolve parts in the main app as well as from our Common assembly so we need to add them to our AggregateCatalog.
Also, for us to be able to use SatisfyImports in modules, we need to make the following call. CompositionHost.Initialize(_container);
Finally, since we're setting a region in the RibbonBar's QATB, we must override ConfigureRegionAdapterMappings() to register our QATBRegionAdapter.
On a final note, this is not a Visual Studio Template but just a solution. You'll have to use Refactoring to rename everything for now but this should be enough to get you setup building modular, LOB apps.
Part II
The above sample utilizes a custom tab control for displaying modules.
However, the Telerik Ribbon control gives us the concepts of using Tab's inside the ribbon. I've updated the sample code so that now modules can load into the ribbons tab controls versus into a completely separate Tab.
To do so, in our MVVM_Template.Common assembly, we add a region to our Telerik RadRibbonBar like so.
Code:
<telerik:RadRibbonBar Grid.Row="0" IsMinimized="False" Margin="0" Regions:RegionManager.RegionName="RootRibbonTabRegion"
HelpButtonVisibility="Visible" HorizontalContentAlignment="Stretch">
We could use a RegionManager in our RibbonGroup here as well if we wanted other Views in our Module1 to be able to add menu items.
Now in our Module1Controller, we load our RootRibbonBarTabView into our region and voila.
I'm more of a hands on than reading so I've tried to make this as short as possible. Any questions, please ask.
What our new work looks like.
11/25/2010 -
The Telerik assemblies are trial versions. You'll need to have a Telerik license to use them in production. Or conversely, you should be able to pull out the Ribbon control and add anything you like in your template with a little work.
Also, I realized that most if like me want the source of anything they use off the internet so they aren't caught in a bad spot. I'm going to upload the MVVM.Framework solution. Mainly right now all it contains is code from the Prism 4 samples for displaying a popup in a region.
Also, the DataWrapper functionality contained within Sasha Barbers Cinch library.







Section Widget
Categories Widget (top-down)

