Mauro Sampietro
Mauro Sampietro

Reputation: 2814

How to get a RoutedEvent knowing its name?

Is there a way to get a reference to a RoutedEvent given its name?

I tried EventManager.GetRoutedEventsForOwner( typeof(ListBox) ).FirstOrDefault( r => r.Name == eventName ) but it return null.

Upvotes: 0

Views: 212

Answers (1)

mm8
mm8

Reputation: 169270

The ListBox class defines no routed events. The Selector base class does though:

string eventName = "SelectionChanged";
var events = EventManager.GetRoutedEventsForOwner(typeof(System.Windows.Controls.Primitives.Selector)).FirstOrDefault( x=> x.Name == eventName);

Upvotes: 1

Related Questions