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 8667399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:57:16+00:00 2026-06-12T17:57:16+00:00

I have a custom behavior inside a DataTemplate, which raises a custom Routed Event.

  • 0

I have a custom behavior inside a DataTemplate, which raises a custom Routed Event. I want to handle that event with a TriggerAction (send a message, invoke a command, etc).

<Border Background="#01FFFFFF" VerticalAlignment="Center">
             <i:Interaction.Behaviors>
                   <Behaviors:MyBehavior>
                        <i:Interaction.Triggers>
                             <i:EventTrigger EventName="MyEvent">
                                    <triggers:SendMessageAction Parameter="ActionTaskAssign" MessageToken="ActionTask" />
                             </i:CustomEventTrigger>
                        </i:Interaction.Triggers>
                    </Behaviors:DropBehavior>
              </i:Interaction.Behaviors>
<!-- .... -->

Yet I can clearly tell, the EventTrigger is NOT subscribing to the behavior’s MyEvent.

  • I’ve tried setting the SourceObject from binding (seen here) but ElementName binding doesn’t seem to work, and neither does FindAncestor
  • I’ve tried inheriting from EventTrigger and setting the SourceObject in code, all I got was a StackOverflowException
  • I’ve tried writing a custom EventTrigger, but I either write one for every custom event (if all hell breaks loose, I will), or I have to figure out a generic way to handle non-generic RoutedEventHandlers…

What should I do?

  • 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-06-12T17:57:17+00:00Added an answer on June 12, 2026 at 5:57 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);
        }
        ....
    

    }

    A related question was asked here :
    Handle MouseDragElementBehavior.Dragging event with void Foo() in VM

    I solved this myself with writing my own custom behavior that fires off a command (which I needed rather then your message.

    You can see my approach in the answer here :

    Custom behavior with command

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

Sidebar

Related Questions

I have a custom behavior for a service where I want to specify a
I have custom classes that I currently instantiate within App.xaml as resources. I want
I have custom event that has several different subscribers who will all use the
Ideally, i would want the entire interface to have a custom styling that is
I want to create custom templated control which controls inside of template coluld be
I have an iFrame inside my document, which at one point triggers a custom
i have a custom behavior extension which i'm using in my client side app.config
In Silverlight 3.0 I have added a custom behavior to some UIElement in Code
I have custom validation rule: public function customRule($check) { } Inside this rule I
I have custom gallery. Gallery represents items that are frame layout. There are one

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.