Source code: CodePlex
Change set: 107164
I am excited about the technology that will permit us to develop cross platform applications; Xamarin provides the ability to program to IOS, Android, and Windows devices. This is a band wagon I am ready to jump on and fortunately there is a toolkit that is paving the way to make this easier for us – the MVVM light toolkit. Although I will be using MVPVM for my application framework design, I will be able to use the components of the toolkit to make this job easier.
It was great to see that Unity is supported by the portable class library, I’ll use this instead of SimpleIoc but I didn't see any support for Prism just yet. This will require me to roll my own until something is available, unlike my efforts in the past (my PasswordMgrV2 folder has a Prism portable class library that I ported) I am going to take a more agile approach and only create the Prism “like” components that I require at each phase of development. I’ll use the MVVM Light toolkit components where applicable, in lieu of creating a Prism “like” component.
The goal for the POC was to modify the MVVM Light template as little as possible while providing MVPVM capabilities. The end result is shown below for this phase of development:
The above screenshots shows four modules (top pane). A module is the equivalent to what you would get if you created a single MVVM Light template – a single view that represents a use case. The four modules in this POC are the menu, status bar, user (left pane), and generator (right pane). At this phase of development they all have the same module code shown above with different views containing the XAML shown below:
The modules reside in a project called MvpVmDesktop while the MVPVM framework resides in project MvpVmPcl, it a portable class library that should port over to Xamarin, we’ll know more when the Visual Studio 2015 Starter license becomes available in a couple of months.
MVVM light developers will feel right at home when they open the POC project as all of the binding and wire-up is the same. I made only the changes shown in red boxes (image below), the bootstrapper is the only new class.
Prism developers should feel right at home with bootstrapper, EventAggregator, and module concepts. I did implement my own ILogger (not Prism’s LoggerFacade) at this point so that I can subscribe to logger events – this allows me to easily send logging information to a textbox (coming soon). This framework is barebones but functional as of this change set.
You’ll notice that in the solution there is a web project (MvpVmWeb). This web project uses the MVC template, I removed the view models from it and moved them into the MvpVmPcl (portable class library project) so that I could use them in the log-in module of the MvpVmPoc (desktop app); reuse of views and view models is where MVPVM shines.
Since the ASP.NET MVC website uses these view models I would not want to add any business logic to them. In MVPVM it is the each module’s presenter (coming soon) responsibility to populate the view models as required allowing the views and view models to remain completely decoupled.
Note: as this framework progresses there will be a Windows Phone, Tablet, Desktop, and Website password manager application that utilizes the same code and view models – only the UI code will be different. When it comes time for IOS and Android, via Xamarin, I should only have to create those UIs as well. NO CODE will reside in views and view models (outside of visual state and bootstrapping) making the transition to other C# supported platforms easy.