Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6587291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:53:55+00:00 2026-05-25T16:53:55+00:00

I am trying to handle the MouseDragElementBehavior.Dragging event on a control I have. See

  • 0

I am trying to handle the MouseDragElementBehavior.Dragging event on a control I have. See here for background on why I want to do this.

I am having trouble wiring up this event. From the XAML you can see I have added a behavior to the user control. Then I attempted to add a handler to the Dragging event on the behavior via the CallMethodAction EventTrigger.

<i:Interaction.Behaviors>
    <ei:MouseDragElementBehavior ConstrainToParentBounds="True">
        <i:Interaction.Triggers>
            <i:EventTrigger EventName="Dragging">
                <ei:CallMethodAction MethodName="NotifyChildrenYouAreDragging" TargetObject="{Binding}"/>
            </i:EventTrigger>
        </i:Interaction.Triggers>
    </ei:MouseDragElementBehavior>
</i:Interaction.Behaviors>

I have tried the following method signatures with no luck:

void NotifyChildrenYouAreDragging(){}
void NotifyChildrenYouAreDragging(object sender, EventArgs e){}
void NotifyChildrenYouAreDragging(object sender, MouseEventArgs e){}

Anyone have experience using triggers to handle events in attached behaviors?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:53:56+00:00Added an answer on May 25, 2026 at 4:53 pm

    The problem is that the EventTrigger doesn’t hook up to the Behavior’s events. Instead it is hooking up to the Behavior’s AssociatedObject’s events. Here is the relevant source code:

     protected override void OnAttached()
        {
            base.OnAttached();
            DependencyObject associatedObject = base.AssociatedObject;
            Behavior behavior = associatedObject as Behavior;
            FrameworkElement element = associatedObject as FrameworkElement;
            this.RegisterSourceChanged();
            if (behavior != null)
            {
                associatedObject = ((IAttachedObject) behavior).AssociatedObject;
                behavior.AssociatedObjectChanged += new EventHandler(this.OnBehaviorHostChanged);
            }
            ....
      }
    

    So you can see that if the associated object of the trigger is a behavior, then it sets the associated object to the Behavior’s associated object which is your items collection. The items collection doesn’t have a dragging event so nothing is ever fired.

    You could probably get the results you want by creating another behavior that checks to see if the associated object has a drag behavior and if so have your behavior attach to the dragging event. Then call the method on the object from there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to handle an event inside an ItemsControl ControlTemplate. I have assigned the
I'm trying to handle a JSONP Callback, I have the following JavaScript var URL
I've been trying to handle the onkeydown event across multiple frames (no, I unfortunately
Hi i am trying to handle an ajax json response here is my code
I'm trying to handle errors that have occurred on other threads the .NET CF
I am trying to handle a mouseclick event on a particular form that should
I'm trying to handle a form which is quite complex for me... We have
I am trying to handle a CSV file via php, and I have it
I am trying to handle dateTime. I have created dateCreated field which is using
I'm trying to handle event after creating new record to ExtJS store and saving

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.