Good day.

I have a window in which UserControl is implemented

<local:iWeekControl/> 

In this control there is an element for which you need to specify a double click handler.

 <ListBox ItemsSource="{Binding}"> <ListBox.ItemContainerStyle> <Style TargetType="{x:Type ListBoxItem}"> <EventSetter Event="MouseDoubleClick" Handler="DoubleClickHandler"/> </Style> </ListBox.ItemContainerStyle> // ... </ListBox> 

It is necessary to make the DoubleClickHandler handler be in the window in which this UserControl is located.

How can this be implemented?

Thank.

  • one
    1 try to remake the team. they bind to the current DataContext (take some EventToCommand implementation) 2 hang up the handler on user control in the target window and already catch and filter the resource of the event, but it's dirty - vitidev

1 answer 1

It may be possible to use InputBindings. I give an example from the code at hand

 <StackPanel.InputBindings> <MouseBinding Command="{Binding Path=DataContext.SelectGroupCommand, RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}}" CommandParameter="{Binding}" Gesture="LeftDoubleClick" /> </StackPanel.InputBindings>