Attaching MVVM Behaviors and Services

To attach the components from DevExpress MVVM Framework (behaviors and services), press the SmartTagCogWheelButton button, then select the required behavior or service from the Add Behavior or Add Service menu.

SmartTagMVVM

The list of available behaviors and services can differ depending on which element is selected.

To add a behavior (for instance, the EventToCommand) open the Smart Tag for the window (click the SmartTagButton button) and press Add Behavior.

SmartTagAddBehavior

Click the EventToCommand item and select the newly added element in the list of behaviors. Set the required properties.

SmartTagMVVMETC

As a result, Smart Tag will generate the following code in XAML.

<dx:DXWindow
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
    ...
    DataContext="{dxmvvm:ViewModelSource Type={x:Type ViewModel:MainViewModel}}">
    <dxmvvm:Interaction.Behaviors>
        ...
        <dxmvvm:EventToCommand Command="{Binding OnLoadedCommand}" EventName="Loaded"/>
        ...
    </dxmvvm:Interaction.Behaviors>
    ...
</dx:DXWindow>

A similar code can be used to manually attach other behaviors from the DevExpress MVVM Framework.