Reputation: 93
I'm having difficulty finding how to register a RoutedEventHandler in UWP. I need to have an event handler in parent class which can control access to all child classes inside it.
Upvotes: 0
Views: 463
Reputation: 7737
Currently UWP cannot customize routing events like WPF. In UWP, you can consider using EventHandler
instead of RoutedEventHandler
:
public class ParentModel
{
public event EventHandler TestEvent;
public void DoSomething()
{
//do other things...
TestEvent?.Invoke(this, EventArgs.Empty);
}
}
Usage
var parent = new ParentModel();
parent.TestEvent += HandleTest;
...
private void HandleTest(object sender, EventArgs e)
{
var parent = sender as ParentModel;
// do something...
}
Thanks.
Upvotes: 1