EventToCommand Syntax

Apr 27, 2010 at 3:27 PM

If you are not using ExpressionBlend 4 what would the syntax for EventToCommand?

Coordinator
Apr 27, 2010 at 3:53 PM

Hi,

The syntax is actually the same if you use Blend or not... except that Blend creates the XAML automatically :) OK OK, I know you know that.

For the XAML syntax, check this post:

http://blog.galasoft.ch/archive/2009/11/05/mvvm-light-toolkit-v3-alpha-2-eventtocommand-behavior.aspx

Cheers,

Laurent

Apr 27, 2010 at 8:26 PM
I get the following error when trying to use in Windows7, VS10. The tag 'EventToCommand' does not exist in XML namespace 'clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras'.
Coordinator
Apr 28, 2010 at 12:57 PM

Hi,

This error is probably due to using the wrong assembly. For WPF4, you should use GalaSoft.MvvmLight.Extras.WPF4.dll which is inside the folder C:\Program Files\Laurent Bugnion (GalaSoft)\Mvvm Light Toolkit\Binaries\WPF4

Let me know if this solves the issue.

Laurent

Apr 28, 2010 at 3:10 PM

That is the file I am using.

Coordinator
Apr 28, 2010 at 4:14 PM

In this case the xmlns is wrong. It should be clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4

Sorry for the confusion, I now realize that I misled you with the link above. The assembly parameter in the xmlns attribute must reflect the name of the assembly without the extension .dll

Cheers,

Laurent

Apr 28, 2010 at 4:28 PM

Ok. One more question. I am using a custom control that has a RoutedEvent called SearchFocusRowChanged. I want to run the EventToCommand for that event. I have the following but it doesn't work.

 What am I doing wrong. 

<foundationv:SearchControl Style="{DynamicResource SearchControlStyle}" SearcherClass="{x:Type searcher:ContactSearcher}" ResultsGridStyle="{DynamicResource ContactGridControlStyle}"  x:Name="mContactSearchControl" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" DataContext="{Binding Searcher}">
                           <i:Interaction.Triggers>
                                   <i:EventTrigger EventName="SearchFocusedRowChanged">
                                       <cmd:EventToCommand Command="{Binding SetCurrentCommand, Mode=OneWay}"
                                           CommandParameter="{Binding SearchFocusedRow, Mode=OneWay}" MustToggleIsEnabledValue="False" />                                       
                                   </i:EventTrigger>
                               </i:Interaction.Triggers>
                       </foundationv:SearchControl>

Coordinator
Apr 30, 2010 at 12:04 PM

Hi,

I am not sure what the issue is, are you sure that the DataContext is set properly? Do you see a Data error in the output tab of Visual Studio when you run the application in debug mode, maybe telling you that the binding to SetCurrentCommand is invalid? Are you sure that the event SearchFocusedRowChanged is executed?

If you cannot find the issue, can you try to make a small repro and send it to me per email?

Cheers,

Laurent

May 3, 2010 at 2:57 PM

I use IdeaBlade for data communication so this would be difficult. I can try just building an app with the controls. Would that work for you?

Coordinator
May 7, 2010 at 9:30 AM

Hi,

Yes, any application where the error is visible.

Thanks,

Laurent