Dapplo.CaliburnMicro
This will help you to get started with bootstrapping Caliburn.Micro (and MahApps or NotifyIcon WPF)
- Documentation can be found here (soon)
- Current build status:
- Coverage Status:
- NuGet package Dapplo.CaliburnMicro:
- NuGet package Dapplo.CaliburnMicro.Dapp:
- NuGet package Dapplo.CaliburnMicro.Configuration:
- NuGet package Dapplo.CaliburnMicro.Translation:
- NuGet package Dapplo.CaliburnMicro.Security:
- NuGet package Dapplo.CaliburnMicro.Security.ActiveDirectory:
- NuGet package Dapplo.CaliburnMicro.ClickOnce:
- NuGet package Dapplo.CaliburnMicro.Wizard:
- NuGet package Dapplo.CaliburnMicro.NotifyIconWpf:
This project is a combination of multiple Dapplo libraries, and brings roughly:
- A bootstrapper for Caliburn.Micro with Autofac
- addons to your application, via Dapplo.Addons. Use MVVM via composition (e.g. you can make a context menu and have the items provided by addons)
- configuration & translations based on interfaces via Dapplo.Config
- Some UI components like System-tray icon, menus, wizard are provided with a MVVM first approach.
- Automatically style your Views via MahApps (if there is a reference to the Dapplo.CaliburnMicro.Metro.dll this will be used automatically)
Available Packages:
- Dapplo.CaliburnMicro, Caliburn.Micro Bootstrapper for Dapplo.Addons which takes care of initializing Autofac and o.a. your IShell ViewModel
- Dapplo.CaliburnMicro.Dapp, adds a replacement for Application which helps to bootstrap
- Dapplo.CaliburnMicro.Configuration, adds a MVVM configuration component and automatic Dapplo.Ini importing
- Dapplo.CaliburnMicro.Translation, adds automatic Dapplo.Language importing
- Dapplo.CaliburnMicro.Security, adds security to your UI
- Dapplo.CaliburnMicro.Security.ActiveDirectory, adds AD-Role based permissions to your UI
- Dapplo.CaliburnMicro.Wizard, adds a MVVM wizard component
- Dapplo.CaliburnMicro.Menu, adds a MVVM menu component
- Dapplo.CaliburnMicro.Toasts, adds a MVVM toasts
- Dapplo.CaliburnMicro.Cards, adds a MVVM adaptive card implementation
- Dapplo.CaliburnMicro.Metro, contains a MetroWindowManager to make it work with MahApps
- Dapplo.CaliburnMicro.NotifyIconWpf, adds functionality to display a system tray icon ViewModel first, via Hardcodet.NotifyIcon.Wpf
- Dapplo.CaliburnMicro.ClickOnce, adds ClickOnce supporting functionality to simplify your
Quick-start documentation
A demo-project is supplied, see: Application.Demo, or Application.Demo.ClickOnce
Dapplo.CaliburnMicro
A Caliburn.Micro support project, with Dapplo.CaliburnMicro.Dapp taking care of bootstrapping Caliburn.Micro with Dapplo.Addons, which takes care of initializing Autofac and o.a. your IShell ViewModel
There is functionality available to support you with building:
- Simplified binding of properties
- Some build in behaviors, like Visibility, IsEnabled and authentication behaviors which hide/disable elements depending on a value.
- Dapplo.CaliburnMicro.Configuration a structured configuration, with a tree where you can hang your "config screens"
- Dapplo.CaliburnMicro.Menu Context menus (with tree support)
- Dapplo.CaliburnMicro.Translations to support translations
- Dapplo.CaliburnMicro.Wizard a simple wizard component
- Dapplo.CaliburnMicro.Security add security behaviour (enables / visible) depending on rights
Usage:
-
Create ViewModels & Views for Caliburn.Micro, make sure you register your viewmodels in an AddonModule (Dapplo.Addon) to Autofac.
-
Implement and register an IShell if you want to have a default "Window" to be opened
-
Create a Dapplication
// Configure your application
var applicationConfig = ApplicationConfigBuilder
.Create()
// Used for logging, configuration, and thread names
.WithApplicationName("application name")
// Used to prevent multiple instances
.WithMutex("<your GUID>")
// Enable the Dapplo.CalliburnMicro libraries
.WithCaliburnMicro()
// Add directories to scan for dlls
.WithScanDirectories("... directory ...")
// Scan for all the assemblies, in the exe directory or specified scan directories, called Greenshot.Addon.*.dll
.WithAssemblyPatterns("Greenshot.Addon*")
.BuildApplicationConfig();
var application = new Dapplication(applicationConfig)
{
ShutdownMode = ShutdownMode.OnExplicitShutdown
};
- Check is the application was already running
if (application.WasAlreadyRunning)
{
// Show message / exit
}
- Run
application.Run();
Dapplo.CaliburnMicro.NotifyIconWpf
This is based on a Hardcodet.Wpf.TaskbarNotification dependency, and supplies code to a have ViewModel first approach for a System-Tray icon
Usage:
- Annotate your ViewModel class with the ExportAttribute, give it the typeof(ITrayIconViewModel) parameter. This make sure it's found and instanciated, you can set the initial visibility (as expected) in the view.
- Make your ViewModel extend the TrayIconViewModel, this forces you to implement the IViewAware from Caliburn.Micro but this can be done by extending e.g. Screen or ViewAware.
- Create a View with a TrayIcon, you don't NEED code behind, e.g.
- TrayIcon extends TaskbarIcon (from Hardcodet.Wpf.TaskbarNotification) and only adds an interface and a minimal implementation. This allows you to use it exactly like the documentation of Hardcodet.Wpf.TaskbarNotification describes. Also due to the way things are wired, all Caliburn.Micro logic works as designed (even cal:Message.Attach="[Event TrayLeftMouseDown] = [Action xxxx]")
- ToolTipText -> The IHasDisplayName interface forces the DisplayName property, this is automatically bound to the ToolTipText
Dapplo.CaliburnMicro.Metro
This is based on a MahApps.Metro dependency, and supplies a IWindowManager implementation which makes things look like "metro" apps.
Note: Dialog boxes are not yet tested or supported... I might need to have a look at this: https://dragablz.net/2015/05/29/using-mahapps-dialog-boxes-in-a-mvvm-setup/
General TODO:
Add better error support