Released Catel 3.9.0

Today we released Catel 3.9.0. This post describes the most important changes. For a detailed list, see the full release notes.

To get the latest bits of Catel, please update via NuGet or get the setup package at GitHub.

Added multilingual support (also via bindings)

Support for multilingual applications has been on our wish list for a long time. In this release we finally found time to actually implement this feature. To bind to resource files which are determined dynamically, simply use the following xaml:

<TextBlock Text="{LanguageBinding WarningTitle}" />

For more information, see the documentation.

Improved handling of unloading of nested views

In previous versions of Catel it was possible that multiple dummy view models were created during the unloading of a large tree of nested views. This occurred when there were at least 3 nested views inside and the total tree was being unloaded from the visual tree. If one of the view models had an empty constructor (thus not using model injection), it was being recreated because the parent data context was changing.

image

As the image above shows, when the DataWindow is being closed in step 2, all view models are closed. However, since the nested views are not yet aware that they are being unloaded (no View.Unloaded event fired yet), it finds out the parent data context changes (from a view model to null), it recreates the view model in step 3.

Catel 3.9.0 improves the behavior by actively being aware that a view is about to be unloaded (occurs before the Unloaded event of a view). This will prevent that the dummy view models are created and make sure that view models are only created when they are actually needed.

Improved IoC component customization

We made it much easier to customize any IoC component in Catel. From now on, the only thing required is to use the following code at the startup of an application:

Catel.IoC.IoCFactory.CreateServiceLocatorFunc = () => new MyCustomServiceLocator();
Catel.IoC.IoCFactory.CreateTypeFactoryFunc = () => new MyCustomTypeFactory();

Catel.IoC.IoCConfiguration.UpdateDefaultComponents();

We have also dropped support for external containers since that is no longer the recommended way to use external containers.

Added CommandManager to create application-wide commands

Application-wide commands are known in WPF, but they are meant to be used as RoutedUIEvents. This does not fit very well in an MVVM-styled application.

Creating commands

To create application-wide commands, one must resolve the ICommandManager from the DependencyResolver and create the command:

var dependencyResolver = IoCConfiguration.DefaultDependencyResolver;
var commandManager = dependencyResolver.Resolve<ICommandManager>();

commandManager.CreateCommand("Refresh", new InputGesture(Key.F5));

Registering commands

When a view model wants to use application-wide specific commands, the only thing it has to do is register the command in the CommandManager.

public class CommandSubscribingViewModel : ViewModelBase
{
    private readonly IMessageService _messageService;

    public CommandSubscribingViewModel(ICommandManager commandManager, IMessageService messageService)
    {
        Argument.IsNotNull(() => commandManager);
        Argument.IsNotNull(() => messageService);

        _messageService = messageService;

        ExampleCommand = new Command(OnExampleCommandExecute);
        commandManager.RegisterCommand("Refresh", ExampleCommand, this);
    }

    public Command ExampleCommand { get; private set; }

    private void OnExampleCommandExecute()
    {
        _messageService.Show("Application-wide command executed");
    }
}

Using application-wide commands in xaml

To make it easy to bind to application-wide commands, Catel provides the CommandManagerBinding markup extension for WPF and Silverlight. To bind to commands in xaml, use the following code:

<Ribbon catel:StackGrid.ColumnSpan="4">
    <RibbonTab Header="Home" KeyTip="H" >
        <RibbonGroup Header="Example commands">
            <RibbonButton Command="{catel:CommandManagerBinding Refresh}" LargeImageSource="..\Resources\Images\Refresh.png"
                          Label="Refresh" KeyTip="F5" />
        </RibbonGroup>
    </RibbonTab>
</Ribbon>

For more information, see the documentation.

Improved support for Windows Phone

We put very much time in improving the Windows Phone development experience with Catel, so if you have not yet written your Windows Phone application using Catel, this is your chance! We improved the LocationService, NavigationService and general handling of things in Windows Phone.

And much more!

These are only the highlights of this major release. To get more information, check out the download section to view the full release notes.