1

Hi all I am trying to implement an on click effect in the items of a listbox but I keep getting this error:

The type 'cmd:EventToCommand' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.

<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 try 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 is the problem and how can I fix it?

user3182266
  • 1,270
  • 4
  • 23
  • 49
  • is the EventToCommand part of Catel ? I thought it was part of prism. Defenetly it is not part of the .NET Framework – S.L. Aug 13 '14 at 07:06
  • soo ...what would the solution be? – user3182266 Aug 13 '14 at 07:08
  • Implement the class yourself or use a Framework like PRISM. If you use Google you will find the source for this class. – S.L. Aug 13 '14 at 07:10
  • Nope found the problem you were wrong EventToCommand is part of the Catel I was just declaring it wrong"http://catel.codeplex.com" – user3182266 Aug 13 '14 at 07:11
  • ah okay :) than everything is okay. @Stian. i dont know in which Framework this Class exists :P – S.L. Aug 13 '14 at 07:12
  • @S.L. Many! ;) Have you added references to Galasoft MVVM Light through nuget user3182266? – Stígandr Aug 13 '14 at 07:15
  • @user3182266 RightClick References on your project, click Manage Nuget Packages. Select Online, search mvvmlight, install MVVM Light Libraries Only. BTW: Your bindings looks off, as desscribed in the other post. – Stígandr Aug 13 '14 at 07:25
  • Ok how can I fix the bindings? Why are they bad? – user3182266 Aug 13 '14 at 07:34

3 Answers3

2

There is a good list of all behaviors and triggers that are 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

Geert van Horrik
  • 5,689
  • 1
  • 18
  • 32
1

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

You can also look at a similar answer here, but I guess your options are either using MVVM-Light if you want to use it, or sorting through he's code and implementing something similar yourself ...

Community
  • 1
  • 1
Noctis
  • 11,507
  • 3
  • 43
  • 82
  • nahh found the problem thanks for your help though iwas declaring the cmd wrong it whould have been xmlns:cmd="catel.codeplex.com" – user3182266 Aug 13 '14 at 07:14
1

Add GalaSoft.MvvmLight library to references. Then

use this xmlns:cmd="clr-namespace:GalaSoft.MvvmLight;assembly=GalaSoft.MvvmLight" instead of xmlns:cmd="http://www.galasoft.ch/mvvmlight"

ebattulga
  • 10,774
  • 20
  • 78
  • 116