Take the 2-minute tour ×

I have a UserControl which acts as a custom button, but since I changed my namespaces around the routed click event no longer works. Essentially my namespaces look something like this:


I have a UI.Controls.CustomButton which has a routed click event implemented something like:

public static readonly RoutedEvent ClickEvent = EventManager.RegisterRoutedEvent(

public event RoutedEventHandler Click
     add { AddHandler(ClickEvent, value); }
     remove { RemoveHandler(ClickEvent, value); }

private void Border_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
     Border_MouseEnter(sender, e);

private void RaiseClickEvent()
     RoutedEventArgs newEventArgs = new RoutedEventArgs(Button.ClickEvent);

And I am trying to use it from within a UI.Pages.SomePage like so:


<controls:CustomButton Text="New..." Click="NewButton_Click"/>


public void NewButton_Click(object sender, RoutedEventArgs e)
    //do something here

When I debug the application I see that RaiseEvent inside my UI.Controls.CustomButton is being hit, but the NewButton_Click inside my UI.Pages.SomePage is never called.

This was working when everything was in the same namespace... am I missing something obvious? Thanks!

share|improve this question
Just to clarify, RoutedEventArgs newEventArgs = new RoutedEventArgs(Button.ClickEvent); should be CustomButton.ClickEvent, no? –  Egor Aug 14 '12 at 15:14
I am an idiot. I refactored as a part of changing the namespace and I guess that slipped through. Thank you so much. If you post that as the answer I will accept it. –  FlyingStreudel Aug 14 '12 at 15:20
Good stuff, glad you got it resolved –  Egor Aug 14 '12 at 15:23

1 Answer 1

up vote 5 down vote accepted
RoutedEventArgs newEventArgs = new RoutedEventArgs(Button.ClickEvent);

should be:

RoutedEventArgs newEventArgs = new RoutedEventArgs(CustomButton.ClickEvent);
share|improve this answer

Your Answer


