EventTrigger does not fire

Apr 5, 2010 at 5:14 PM
Edited Apr 5, 2010 at 5:14 PM

Hi,

In the following example the 'MouseEnter' event in my user control fires up the 'btLogin_MouseEnter' method, but not the LoginCommand.

<uc:TextButton
  x:Name="btLogin"
  Text="login"
  MouseEnter="btLogin_MouseEnter" 
  >
  <i:Interaction.Triggers>
    <i:EventTrigger EventName="MouseEnter">
      <cmd:EventToCommand Command="{Binding LoginCommand}" />
    </i:EventTrigger>
  </i:Interaction.Triggers>
</uc:TextButton>

If I use the trigger within a standard control it works just fine:

<TextBlock 
  Text="login" 
  >
  <i:Interaction.Triggers>
    <i:EventTrigger EventName="MouseEnter">
      <cmd:EventToCommand Command="{Binding LoginCommand}" />
    </i:EventTrigger>
  </i:Interaction.Triggers>
</TextBlock>

Any idea? Has this to do with the mvvm light toolkit?

Thank you,
Ueli

Coordinator
Apr 18, 2010 at 10:20 PM

Hi

Sorry for the delay. I tried this scenario with a TextBlock, with an attached EventToCommand and also an event handler for the same event (MouseEnter) and it works fine. I am not sure what the TextButton control is doing. There are multiple ways where this might fail

  • Are you marking the event as handled in the event handler?
  • Are you sure that the command is bound correctly? If you try with the command but without the MouseEnter event handler, does the command work?

Cheers,

Laurent

Jul 15, 2010 at 11:56 AM
Edited Jul 15, 2010 at 11:57 AM
Had same problem. LoginCommand never fired, and it was properly defined, almost properly. The reason was that I missed "public" modiffier before definition of RelayCommand<object> LoginCommand. Binding seemd to be ok but commmand never fired. Stupid mistake but maybe will save somones time.