MVVM EventToCommand not found

Hi all, I am trying to implement a click effect on list items, but I keep getting this error:

The type 'cmd: EventToCommand' was not found. Make sure that you have not provided an assembly reference and that all referenced assemblies have been generated.

<catel:UserControl
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:catel="http://catel.codeplex.com"
         xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
         xmlns:cmd="http://www.galasoft.ch/mvvmlight"
         mc:Ignorable="d" 
         d:DesignHeight="300" d:DesignWidth="300">

      

And the code where I am trying to implement the on click method:

<Grid>
    <ItemsControl ItemsSource="{Binding Source={StaticResource cvsRoutes}}">
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <Expander Header="{Binding Name}" MinHeight="50">
                    <ListBox>
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="PreviewMouseLeftButtonDown">
                                <cmd:EventToCommand Command="{Binding PreviewMouseLeftButtonDownCommand}" PassEventArgsToCommand="True"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                        <TextBlock Text="Something" >
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="KeyUp">
                                <cmd:EventToCommand Command="{Binding KeyUpCommand}" PassEventArgsToCommand="True"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                        </TextBlock>
                        <TextBlock Text="Something" />
                        <TextBlock Text="Something" />
                        <TextBlock Text="Something" />
                        <TextBlock Text="Something" />
                    </ListBox>
                </Expander>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
</Grid>

      

Can you tell me what the problem is and how can I fix it?

+1


source to share


3 answers


There is a good list of all the behaviors and triggers available in Catel and how you can use them:

https://catelproject.atlassian.net/wiki/pages/viewpage.action?pageId=1409064



It also includes EventToCommand:

https://catelproject.atlassian.net/wiki/display/CTL/EventToCommand

+2


source


EventToCommand

is part of MVVM-Light ... Here's an article on MSDN by MVVM light (Laurent Bugnion) where he talks about how to use it.



You can also look at a similar one here , but I think your options either use MVVM-Light if you want to use it, or sort by its code and implement something like yourself ...

+1


source


Add library GalaSoft.MvvmLight

to links. Then

use xmlns:cmd="clr-namespace:GalaSoft.MvvmLight;assembly=GalaSoft.MvvmLight"

insteadxmlns:cmd="http://www.galasoft.ch/mvvmlight"

+1


source







All Articles