I have a hierarchical structure of UserControls that I need to have a custom RoutedEvent to work with. What I need is to be able to have a parameter bubble through the hierarchy of controls with certain controls modifying the parameter so that when the event bubbles up to the base of the hierarchy I have a URI-like parameter that describes the path it took.
So far I have created a class derived from RoutedEventArgs that adds a String parameter to the event argument.
Public Class ShowAsEventArgs
Public Sub New(ByVal evt As RoutedEvent, ByVal myName As String)
mFieldPath = myName
Private mFieldPath As String
Public Property FieldPath As String
Set(value As String)
mFieldPath = value
I have also defined the routed event:
Public Shared ReadOnly ShowAsFieldEvent As RoutedEvent = EventManager.RegisterRoutedEvent("ShowAsField", RoutingStrategy.Bubble, GetType(RoutedEventHandler), GetType(BitField))
Public Custom Event ShowAsField As RoutedEventHandler
AddHandler(value As RoutedEventHandler)
RemoveHandler(value As RoutedEventHandler)
RaiseEvent(sender As Object, e As BitField.ShowAsEventArgs)
The problem I am having is adding a handler for this event, I tried this:
AddHandler BitField.ShowAsFieldEvent, AddressOf HandleShowAsFieldEvent
However, I get an error that says that "ShowAsFieldEvent" is not an event of "BitField".
I spite of lots of searches I am unable to find an example of how to do this. Any input would be much appreciated.