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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:43:03+00:00 2026-05-27T16:43:03+00:00

I have an event in my MainWindow that is being fired from one of

  • 0

I have an event in my MainWindow that is being fired from one of my child controls as a routed event. The MainWindow has an AddHandler call to catch the routed fire.

I would like to fire this same event from ANOTHER child element, but this element (a menuItem) gets created on the fly so when I try to use AddHandler in MainWindow, like:

 this.AddHandler(MyMenuItem.EditExtensionsEvent, new RoutedEventHandler(this.EditExtensions));

I get a null argument exception because MyMenuItem does not exist yet.

Anyone know of a way that I can still use a routed event?

  • 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-27T16:43:03+00:00Added an answer on May 27, 2026 at 4:43 pm

    I assume your MyMenuItem is either not in the namespace of your application or the EditExtensionsEvent isn’t a static RoutedEvent of the class MyMenuItem.

    It should look something like this:

    public class MyMenuItem
    {
    public static readonly RoutedEvent EditExtensionsEvent
    ..
    }
    

    see http://msdn.microsoft.com/en-us/library/ms752288.aspx

    If it is declared this way it should work as you’ve shown here

    EDIT:
    I’d suggest registering with an already existing event to make sure your EditExtensionsEvent is working properly.

    public MainWindow()
    {
      ..
      this.AddHandler(MenuItem.ClickEvent, new RoutedEventHandler(this.MenuItemClick));
    }
    
    private void MenuItemClick(object sender, RoutedEventArgs e)
    {
       MessageBox.Show("Clicked");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an object that has a timer and it throws an event when
I have a UserControl, we'll call it myUC , that is one among several
I have a program whereby Data is being sent from one computer to another
I have MainWindow with a button, under the button click event I want MainWindow
I have event Button that creates text box in run time. Private Sub Button1_Click(ByVal
I have event manager process that dispatches events to subscribers (e.g. http_session_created, http_sesssion_destroyed). If
If have an event that fires when a user clicks outside of text field,
I have a WPF window that enables glass on itself during its SourceInitialized event.
I have one MainWindow.xib file. I have one label and one button on first
I have a DataGrid that I am creating and populating from code. When the

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.