EventCommander Mappings to bubled events

Jun 22, 2010 at 3:26 PM

Hi Mark,

I'm trying you helpers library and I'd like to bind command to an event fired by Item in ItemsControl (in my scenario TreeViewItem.Expanded). Can I use the EventCommander markup? Something like the next sample - expanded event on TreeViewItem would take it's DataContext and pass it as a parameter to Command bounded on TreeView:

<TreeView>
    <julmar:EventCommander.Mappings>
        <julmar:CommandEvent Event="Expander.Expanded" 
            Command="{Binding DirectoryLoadCommand}"
            CommandParameter="{Binding Path=DataContext, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type TreeView}}}" />
    </julmar:EventCommander.Mappings>
</TreeView>

 

Coordinator
Dec 23, 2010 at 3:32 PM

Hi,

EventCommander was only looking at regular .NET events - not routed events that are attached.  Try the latest release (4.02) and see if it solves your issue.  If EventCommander cannot find a .NET event on the target object, then it looks for a RoutedEvent registered with the specified name (Type.RoutedEventName) and, if the target is a FrameworkElement, uses AddHandler to register to it.