There are lots of lightweight MVVM frameworks out there, which work great for the basics. However, if you are writing larger enterprise applications, notifying the UI of changed properties isn’t enough. For example, did you think about Command Authentication? Or what about sensor emulation for Windows Phone 7 (that Microsoft don’t provide)?

Why auditing

 There are many reasons why auditing should be added to an application. Most developers only add auditing to the database, but below are several reasons to add auditing to the client as well:

With the auditing capabilities of Catel, you can create and register custom auditors that can handled changes and events of view models. This way, you can gather a lot of statistics or any information that you want to gather about the user experience. Below is a list of events that can be handled:

The developer has all the freedom to handle one or more methods in an auditor. Of course multiple auditors are possible as well.

Creating an auditor

Creating a new auditor is very simple. Create a new class, derive from AuditorBase and override the methods you are interested in. The class example tracks the event to a fake analytics framework.

/// <summary>
/// Logs all commands to a custom analytics service.
/// </summary>
public class CommandAuditor : AuditorBase
    private Analytics _analytics = new Analytics();
    /// <summary>
    /// Called when a command of a view model has just been executed.
    /// </summary>
    /// <param name="viewModel">The view model.</param>
    /// <param name="commandName">Name of the command, which is the name of the command property.</param>
    /// <param name="command">The command that has been executed.</param>
    /// <param name="commandParameter">The command parameter.</param>
    public override void OnCommandExecuted(IViewModel viewModel, string commandName, ICatelCommand command, object commandParameter)
        _analytics.TrackEvent(viewModel.GetType(), "commandName");

Registering an auditor

 Registering a new auditor is extremely easy as you can see in the code below:

AuditingManager.RegisterAuditor(new CommandAuditor());


We would like to thank the following contributors:

Want to contribute to the documentation? We have a guide for that!


Have a question about Catel? Use StackOverflow with the Catel tag!