troubleshooting Question

Raising Events in WPF

Avatar of monserob
monserobFlag for United Kingdom of Great Britain and Northern Ireland asked on
.NET ProgrammingVisual Basic.NETMicrosoft Development
3 Comments1 Solution615 ViewsLast Modified:
I want to raise events from a user control and no matter how much I read up on routed events in WPF I just can't seem to get my head totally around them.

I've just about figured out how to raise an event from a user control and handle that event in the parent window but in one particular scenario the user control is actually contained within another user control which is then contained within a parent window. Is it a case of raising the event in the user control, catching it in the parent user control and raising it again to be caught in the parent window?

Also, I've been using code similar to the below; what does this do? The reason I ask is that my events still seem to fire if I comment this out so I'm not sure what the purpose of this is

    Public Custom Event PaymentDetailsChanged As PaymentDetailsChangedHandler
        AddHandler(ByVal value As PaymentDetailsChangedHandler)
            Me.AddHandler(PaymentDetailsChangedEvent, value)
        End AddHandler

        RemoveHandler(ByVal value As PaymentDetailsChangedHandler)
            Me.RemoveHandler(PaymentDetailsChangedEvent, value)
        End RemoveHandler

        RaiseEvent(ByVal sender As Object, ByVal e As PaymentDetailsChangedArgs)
        End RaiseEvent
    End Event

Any suggestions of what I should actually be doing would be great, code examples preferably in VB.Net

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros