FUCKING EVENTTOCOMMAND DOESN T WOR

Dec 27, 2012 at 6:28 PM

Why the hell this fucking little thing doesn't work in VS 2012 ???

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


        xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4"


        xmlns:cmd=?????????????????????????????????????????????????????????????????????????"

Coordinator
Dec 27, 2012 at 6:42 PM

Assuming that you work with WPF4 indeed, it should be

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

What happens when you try that?

Laurent

Dec 27, 2012 at 7:11 PM

Sorry for my first post, I was upset...

 

I'm using .NET 4.5, with the MVVM Light 4.5 WPF project template, so I assume the good assemblies are referenced.

When I try to use EventToCommand in this XAML: 

<Rectangle Fill="BlueViolet"
                 Width="{Binding Width}"
                 Height="{Binding Height}">
<i:Interaction.Triggers>
    <i:EventTrigger EventName="MouseDown">
    </i:EventTrigger>
</i:Interaction.Triggers>
</Rectangle>

I lost the intelisence and when I try to put cmd:EventToCommand tag VS tell me that: 

`Error 1 The name "EventToCommand" does not exist in the namespace "clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.WPF4".`

 

Thanks for your answer.

Coordinator
Dec 27, 2012 at 7:13 PM

Hi,

No worries.

For WPF 4.5, you need to use the correct assembly name GalaSoft.MvvmLight.WPF45 and not GalaSoft.MvvmLight.WPF4.

Side note: There is a reason why I am using the WPF45 in the assembly name, but I am reconsidering it and it is very possible that I will remove that from a future version of MVVM Light.

Let me know if it still doesn't work with the correction.

Thanks
Laurent 

Coordinator
Dec 27, 2012 at 7:14 PM

BTW in VS12, you can type simply xmlns:cmd= and then VS12 should open an Intellisense window proposing the correct namespaces to you.

Cheers

Laurent

Dec 27, 2012 at 7:54 PM

I already tried with 45, but it didn''t worked at all (VS send an error).

In the intellisense pop up there's only the 4 version ("clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.WPF4").

Coordinator
Dec 27, 2012 at 7:58 PM
Edited Dec 27, 2012 at 7:58 PM

Hi,

It sounds like you are using the WPF 4 DLLs with a WPF 4.5 project. Can you send me the project and I'll take a look.

Cheers
Laurent

Dec 27, 2012 at 8:10 PM
Edited Dec 27, 2012 at 8:10 PM

Even when I create a new MVVM Light WPF 45 project, it adds dlls for .NET 4: 

http://img4.hostingpics.net/pics/324142Capture.png

Coordinator
Dec 27, 2012 at 8:18 PM

Seems that you are absolutely right. The project template is faulty. You are the first to report this issue, sorry for that.

I will fix it ASAP. In the meantime, please download the following Zip file:

http://sdrv.ms/UUyOfU

Then right click on the zip file and select Properties. Click on the Unblock button. Then extract the file.

In your project, remove the WPF 4 references and replace with the WPF 4.5 references. In the XAML, use WPF45 instead of WPF4.

Sorry for the inconvenience, but thanks for reporting the issue. 

Cheers
Laurent 

Dec 27, 2012 at 8:48 PM

Thanks for your answers.

Jan 7, 2013 at 4:45 AM
Edited Jan 7, 2013 at 5:17 AM

I have been struggling with EventToCommand and MouseMove.  I have tried binding to my ViewModel and to my View, but nothing fires.  Please help..

I am working with Silverlight 4, NOT WPF.  I think I saw somewhere that EventToCommand does not work with Silverlight except for the Load event.  Bbut for the life of me I can not find that post again.

I have pasted my code and XAML below for your review.  Thanks!

 

 

    Public Shared ReadOnly MouseMoveCommandProperty As DependencyProperty = DependencyProperty.Register("MouseMoveCommand", GetType(RelayCommand(Of MouseEventArgs)), GetType(MyViewModel), Nothing)
    Public Property MouseMoveCommand As RelayCommand(Of MouseEventArgs)
        Get
            If GetValue(MouseMoveCommandProperty) Is Nothing Then
                Return New RelayCommand(Of MouseEventArgs)(Sub(e) MyMouseMove(e))
            Else
                Return DirectCast(GetValue(MouseMoveCommandProperty), RelayCommand(Of MouseEventArgs))
            End If
        End Get
        Set(ByVal value As RelayCommand(Of MouseEventArgs))
            Me.SetValue(MouseMoveCommandProperty, value)
            RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(MethodBase.GetCurrentMethod().Name.Substring(4)))
        End Set
    End Property

 

    Public Sub MyMouseMove(e As MouseEventArgs)
        Dim p As Point = e.GetPosition(e.OriginalSource)
    End Sub

 

<Canvas x:Name="MyCanvas" Cursor="{Binding ActionType, Source={StaticResource MyVM}, Mode=OneWay, Converter={StaticResource ActionToCursor}}" 
                    MouseLeftButtonDown="Canvas_MouseLeftButtonDown"
                    MouseLeftButtonUp="Canvas_MouseLeftButtonUp">

                <i:Interaction.Triggers>
                    <i:EventTrigger>
                        <cmd:EventToCommand Command="{Binding MouseMoveCommand, Source={StaticResource MyVM}}" PassEventArgsToCommand="True"/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
</Canvas>
Jan 7, 2013 at 5:13 AM
Edited Jan 7, 2013 at 5:14 AM

For what it is worth...  This works fine:

        Public _initializeSystemCommand As ICommand = New SystemEx.Commands.DelegateCommand(AddressOf InitializeSystem, AddressOf CanExecute)
        Public Property InitializeSystemCommand() As ICommand
            Get
                Return _initializeSystemCommand
            End Get
            Set(ByVal value As ICommand)
                _initializeSystemCommand = value
            End Set
        End Property

        Private Sub InitializeSystem(parameter As Object)
            'Do something interesting
        End Sub

<Canvas Height="768" Width="1024" Background="LightGray" Cursor="Arrow" DataContext="DrawingVM" >
        <i:Interaction.Triggers>
            <i:EventTrigger EventName="Loaded">
                <i:InvokeCommandAction Command="{Binding InitializeSystemCommand, Source={StaticResource DrawingVM}, Mode=TwoWay}" CommandParameter="L" />
            </i:EventTrigger>

</Canvas

Jan 7, 2013 at 5:23 AM

Here is a cut and paste out of your on Drag&Drop with EventToComand....  However, I can confirm that the code does NOT execute or I would receive notification of the mouse move through Messaging which notifies other elements of the event.

 

An issue with Visual Studio 2010

In the course of preparing this article, I noticed an issue in Visual Studio 2010 when I attempt to debug the HandleDropCommand implementation. Even with a breakpoint placed within the code, the debugger does not break. I am not sure right now what is the reason, and the code does get executed, but this complicates debugging of course. I am investigating and talking to Microsoft about that, but right now I am not sure where it comes from.

Jun 3, 2013 at 3:01 PM
Hello Mr. Bugnion,

I am using MVVM Light toolkit with WPF4.5. I am facing the same issue reported by Yield.

I removed assemblies from my project and added those from zip you suggested, still VS2012 not able to find EventToCommand. And following error message are displayed.

Error Messages:
The type 'cmd:EventToCommand' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.
The name "EventToCommand" does not exist in the namespace "clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.WPF45".

I have also added following xmlns (using IntelliSence) as you suggested however VS2012 still not working.
xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.WPF45"

Can you please help with this?

Thanks.
Jun 4, 2013 at 8:08 AM
Hi Laurent,

In-case you want the code, please let me know How can I send it to you?

Thanks
Jun 26, 2013 at 9:48 AM
Edited Jun 26, 2013 at 9:48 AM
Hi, I recently updated to the latest SL5 version using nuget and exactly hit the same error

Using VS 2012
GalaSoft.MvvmLight.Extras.SL5 (4.1.27.22814)
GalaSoft.MvvmLight.SL5 (4.1.27.22814)

Tried namespaces
xmlns:m="http://www.galasoft.ch/mvvmlight"
xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.SL5"

Error:
The name "EventToCommand" does not exist in namespace....


Help would be really appreciated
thanks
Jun 27, 2013 at 11:15 AM
I am still not able to solve this issue. I tried out everything I can. I think a new thread should be started for this issue.
Jul 26, 2013 at 2:28 PM
I believe you need the "Extras" library. EventToCommand is not part of MVVM Light Essentials. Try xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF45"
Jul 26, 2013 at 2:45 PM
Edited Jul 26, 2013 at 2:46 PM
I believe you need the "Extras" library. EventToCommand is not part of MVVM Light Essentials. Try xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF45"
Jul 29, 2013 at 6:31 AM
Same issue here.
I tryed with
xmlns:mt="clr-namespace:GalaSoft.MvvmLight.Ioc;assembly=GalaSoft.MvvmLight.Extras.SL5"
without success.
So I defined a
using GalaSoft.MvvmLight.Command;
namespace MyNamespace.Common.Views
{
    public class MyEventToCommand : EventToCommand
    {
    }
in code behind and then it works great:
xmlns:views="clr-namespace:MyNamespace.Common.Views"
...
 <views:MyEventToCommand Command="{Binding MyCommand}"
                        PassEventArgsToCommand="True" />
Jul 29, 2013 at 6:38 AM
Oh, that Ioc. Sorry, my falut.

@snwiem
xmlns:mt="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.SL5"
Apr 8 at 1:28 PM
Edited Apr 8 at 1:31 PM
this discussion is fucking codeplex gold. i laughed so hard just seeing this at google results page.