Command not found in bound ICommand

Aug 8, 2011 at 6:51 AM
Edited Aug 8, 2011 at 6:55 AM

Hi,

I am using the Behaviours\BindableCommand.cs and Behaviours\EventCommander.cs together with Prism v4 for my MVVM project.

 

Most of the time the binding of events are work perfectly, but sometimes it appears that certain user control files (is a xaml file) hardly detect the binding of certain events like user control's "Loaded" event, however "Unloaded" event works fine in this case.

When I check the Output windows, i got this message: Missing Command on event handler, Loaded: Sender=Core.RegionAttributeView, EventArgs=System.Windows.RoutedEventArgs

Sample code:

<UserControl ... >

<commonBehaviors:EventCommander.Mappings>
        <commonBehaviors:CommandEvent Command="{Binding LoadedCommand}" Event="Loaded"/>      <-- This is not bind
        <commonBehaviors:CommandEvent Command="{Binding UnloadedCommand}" Event="Unloaded"/>  <-- This is bound, work fine.
    </commonBehaviors:EventCommander.Mappings>

<Grid>
</Grid>
</UserControl>

This issue only happen to those user control that 'injected' programmatically into another user control/window, for example: user control wrapped with Windows control, or user control added in stack panel control by using Children.Add(...).

 

Environment:

.Net 4.0, WPF, Vista 32-bits/Windows 7, VS2010

 

Anybody able to advise on this? Thanks.

Coordinator
Aug 27, 2011 at 5:34 PM

Hi,

Can you create a simple demonstration application - I'd be happy to take a look.

mark