0

I have a Usercontrol (UC1) which contains a list of other UCs (UC2), i want to raise an event in my UC2 when something is modified in it and catch it in UC1, so i declared it like that :

In my UC2 Class :

public static readonly RoutedEvent LiaisonModifieeEvent = EventManager.RegisterRoutedEvent(
    "ModificationOccured", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(UC2));

In the consructor of my UC1 Class :

this.AddHandler(UC2.LiaisonModifieeEvent, new RoutedEventHandler(ModificationOccuredEvent_Handler), true);

And the declaration of my handling method

private void ModificationOccuredEvent_Handler(object sender, RoutedEventArgs e)
    {
        e.Handled = true;
        SaveCablingLinkButton.IsEnabled = true;
    }

Seems that i'm missing something, but i can't see what, the event never is catched in UC1.

EDIT : i forgot to mention the raising part

Somewhere in UC2

RaiseEvent(new RoutedEventArgs(UC2.LiaisonModifieeEvent, this));
Sicha
  • 139
  • 1
  • 12
  • What you posted seems to be in order. Can you also post how you raise you event? – dkozl Jun 21 '13 at 10:40
  • Are you wiring the UC1 handler after UC2 receives the loaded event? – Gayot Fow Jun 21 '13 at 10:43
  • @dkozl : done :) Garry Vass : yep the loading of UC2s happens after the construction of UC1 – Sicha Jun 21 '13 at 11:16
  • @Sicha: I've just copied your code and my `UC1` catches event raised in any `UC2` control as expected – dkozl Jun 21 '13 at 11:32
  • @Sicha if you need to compare your code with mine then [here](http://db.tt/lIafuybM) it is. Your code should work. – dkozl Jun 21 '13 at 11:50
  • Well, i thought my UC2 were created when i added my handler but it seems that it was not. Thanks guys for your time, it is solved :) – Sicha Jun 21 '13 at 11:54

0 Answers0