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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:19:33+00:00 2026-05-12T10:19:33+00:00

I have added an event to a user control, and I call the event

  • 0

I have added an event to a user control, and I call the event in the consumer window of the user control,

My question is: what code does the compiler generate when we assign an event handler through the IDE?

So that I can also use something similar to write the event handler at runtime automatically.

I know we can write an event handler e.g my event handler that I write here:

SearchControl.SearchChangedEvent += new RoutedEventHandler(SearchControl_SearchChanged);

The error thrown in this case is that there is no overload matching, so I try to do the same thing that the compiler does through code. How does the compiler automatically know the arguments?

EDIT: Solution.

I found the area of concern where I was confused in this article: http://msdn.microsoft.com/hi-in/magazine/cc785480%28en-us%29.aspx

In “Routed Events overview” section, the author writes:

To see this, go to the constructor for
your class, right-click on the
InitializeComponent method call, and
select Go To Definition from the
context menu.The editor will display a
generated code file (with a naming
convention of .i.g.cs or .i.g.vb)
containing the code that is normally
generated at compile time.

I found the code behind generated !!

#line 6 "..\..\Window1.xaml"
this.myButton.Click += 
  new System.Windows.RoutedEventHandler(
  this.myButton_Click);

Thanks, for those who were a bit confused with the problem statement. I hope this makes it clear now (it was like I couldn’t explain the problem until I found the solution 🙂

  • 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-12T10:19:34+00:00Added an answer on May 12, 2026 at 10:19 am

    You fully described your SearchControl_SearchChanged function the second you passed it as a parameter to the delegate RoutedEventHandler. From MSDN, The delegate takes 2 parameters, an object and a RoutedEventArgs, and returns void. That right there is what the IDE uses to build the SearchControl_SearchChanged function header for you automatically.

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

Sidebar

Related Questions

I have simple web user control (the code I found somewhere in the web):
I have simple user control with include ajax control - CalendarExtender. This is code:
I have a page and a user control — we'll call them Detail.aspx and
Basically, I have a drop down list and a dynamically added user control. The
I have added the following gesture recognizer to my user control: UIRotationGestureRecognizer *rotate =
I have an XmlSerializer object, and I have added 2 event handlers to the
I have added an EventHandler for the Click-event to a picturebox but on runtime
We are facing a strange problem. We have a user control written in WPF
In my user control I have several textboxes e.g. Textbox1, Textbox2. In the parent
I have user control inside a page with single repeater. The problem is when

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.