1

I tried with a behavior with no luck

Behavior:

    public sealed class BubbleDoubleClickEvent : Behavior<UIElement>
    {
        #region TargetElement
        public UIElement TargetElement
        {
        get { return (UIElement)GetValue( TargetElementProperty ); }
        set { SetValue( TargetElementProperty, value ); }
    }

    // Using a DependencyProperty as the backing store for TargetElement.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty TargetElementProperty =
        DependencyProperty.Register( "TargetElement", typeof( UIElement ), typeof( BubbleDoubleClickEvent ) );
    #endregion

    protected override void OnAttached()
    {
        base.OnAttached();
        AssociatedObject.PreviewMouseDown += AssociatedObject_PreviewMouseDown;
    }

    private void AssociatedObject_PreviewMouseDown( object sender, MouseButtonEventArgs e )
    {
        if( e.ClickCount == 2 )
        {
            e.Handled = true;
            var e2 = new MouseButtonEventArgs( e.MouseDevice, e.Timestamp, e.ChangedButton );
            e2.RoutedEvent = Control.PreviewMouseDoubleClickEvent;

            var target = TargetElement ?? AssociatedObject;
            target.RaiseEvent( e2 );
        }
    }

    protected override void OnDetaching()
    {
        AssociatedObject.PreviewMouseDown -= AssociatedObject_PreviewMouseDown;
        base.OnDetaching();
    }
}

XAML:

<Grid>
   <ContentPresenter x:Name="contentPresenter" Content="{Binding}"    ContentTemplate="{Binding ..., Path=ItemTemplate }" />

   <Thumb x:Name="moveThumb" >
        <i:Interaction.Behaviors>
            <behaviors:BubbleDoubleClickEvent TargetElement="{Binding   ElementName=contentPresenter}"/>
        </i:Interaction.Behaviors>
   </Thumb>
</Grid>

Any help appreciated

lokusking
  • 7,396
  • 13
  • 38
  • 57
Mauro Sampietro
  • 2,739
  • 1
  • 24
  • 50

1 Answers1

0

The code above works just well, but the target control did not receive the event OnPreviewMouseDoubleClick so i had to add an instance handler to manage the event like this:

 this.AddHandler( Control.PreviewMouseDoubleClickEvent,
     new MouseButtonEventHandler( ( target, args ) =>
     {
       //do stuff
       args.Handled = true;
     } ), false );
Mauro Sampietro
  • 2,739
  • 1
  • 24
  • 50