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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:20:18+00:00 2026-05-26T11:20:18+00:00

My question is very similiar to this: ( Binding events to buttons in an

  • 0

My question is very similiar to this: (Binding events to buttons in an ItemsControl) but I didn’t found a solution there.
I have an ItemsControl and inside its DataTemplate, I have another ItemsControl. The items in the outer control contain classes that have some properties, and one of the properties is a collection. The inner ItemsControl source is binded to this collection, and inside the inner controls DataTemplate there is a Button.

My problem is that when I wire up an event for the button (.. Click=”dummyfunc”) and try to run the project, I get an unhandled XamlParseException (4004) and says that “Failed to assign to property ‘System.Windows.Controls.Primitives.ButtonBase.Click'”
I declared my event handler in the CodeBehind of the page in which the outer ItemsControl is placed in the Xaml. And it works fine for the buttons placed in the outer controls DataTemplate. But in the inner controls template, I just cant wire up any events.

One thing works:

<HyperlinkButton  Content="x">
     <i:Interaction.Triggers>
         <i:EventTrigger EventName="Click">
             <ei:CallMethodAction MethodName="DeleteMe" TargetObject="{Binding}"/>                            
         </i:EventTrigger>
     </i:Interaction.Triggers>             
</HyperlinkButton>

But this triggers only a method (DeleteMe) which is implemented in the item I mentioned above, that has some properties and a collection.

But instead of this, I need to handle the events in the inner control with a usual method:

public void dummyfunc(object sender, RoutedEventArgs e){...}

(so i can get the button that fired the event for example:

sender as HyperinkButton 

or

e.OriginalSource as HyperlinkButton

I suppose the problem is that the event is not bubbled up and I get the parse exception because the parser cannot find the event handler declaration in the actual scope, which apparently is not the CodeBehind for the inner control 🙁

The reason I need this, is because I would like to do some custom UI logic in code, and trigger the DeleteMe logic somehow only after this.

Thanks,
Bálint

  • 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-26T11:20:18+00:00Added an answer on May 26, 2026 at 11:20 am

    It’s not obvious from the spartan documentation for CallMethodAction, but the method named by the MethodName property can have either of these signatures:

    • void Method()
    • void Method(object associatedObject, object parameter)

    Furthermore, the default parameter for an EventTrigger action is the event arguments value that would normally be passed as the second argument to an event handler. For the Click event, the type of the parameter is RoutedEventArgs so you can define your DeleteMe method like this:

    public void DeleteMe(object sender, RoutedEventArgs e)
    {
        Debug.WriteLine("sender: {0}", sender);
        Debug.WriteLine("e.OriginalSource: {0}", e.OriginalSource);
    }
    

    This gives you access to all the information you desire when handling the Click event.

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

Sidebar

Related Questions

I know that this is a repeated question. I have found very similar questions
This is a very similar question to Backbone not binding events to jQuery Popover
I've found this question very similar to my situation, but I don't know basic
I have a question very similar to this one but the answer does not
Question is very similiar to this find duplicates but I'd like to find only
I see that there is a very similiar question already answered that discusses this
There is a question very similar to this but I wanted to ask it
My question popped up a very similar question, this one . But the accepted
This may be a very dumb question but I can't seem to get it
I have a question very similiar to another question: Get name of property as

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.