I have a class that needs to notify that something significant has occurred. The class is in a WPF-project, even though this specific class, is lookless (and doesn't inherit from UIElement
, neither directly or indirectly).
Normally, I just register a RoutedEvent
to get this functionality but as this class neither has AddHandler nor RemoveHandler, I can't get it to work. Anyone knows of another way of get the RoutedEvent
behaviour?
As far as I know, if your class isn't a
UIElement
, it cannot be part of the visual tree, and if it isn't part of the visual tree, you cannot throwRoutedEvent
s. They're strictly a UI concept.I think the recommended approach would be to either make your class inherit from
UIElement
, or if that's not possible/desired, create a counterpart for your class which does inherit fromUIElement
and use this second class in the visual tree where you would normally place your original class.