Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
130
Which EventHandler to use for EditModeValidationErrorEvent when creating eventsetter in code
posted

I'm building a XamMaskedEditor style that sets an event handler for the EditModeValidationErrorEvent. I can't figure out what EventHandler to use. If I use RoutedEventHandler (and RoutedEventArgs). I get a runtime error that the handler is invalid (which makes sense). I can't find an EditModeValidationErrorEventHandler class to build the delegate with.

How do I construct the event setter here?
Thanks

Private Sub ApplyStyle()

    Dim style As New Style(GetType(Infragistics.Windows.Editors.XamMaskedEditor))
    style.Setters.Add(New EventSetter(XamMaskedEditor.EditModeValidationErrorEvent, New ????EventHandler(AddressOf ValidationError)))
    MyBase.EditorStyle = style
End Sub

Private Sub ValidationError(sender As Object, e As EditModeValidationErrorEventArgs)

End Sub

Parents
  • 2680
    Suggested Answer
    Offline posted
    Hello Harry,

     

    Thank you for the provided code-snippet.

     

    I have been looking into your question and determined that the EventSetter constructor accepts a handler as Delegate, which represents the method that will handle the event when it provides data and where the Delegate’s signature is:
    Public Delegate Sub EventHandler(Of TEventArgs)(sender As Object, e As TEventArgs)

     

    Therefore, the EventSetter can be defined as follows:

     

    Private Sub ApplyStyle()
            Dim style As New Style(GetType(XamMaskedEditor))
            style.Setters.Add(New EventSetter(XamMaskedEditor.EditModeValidationErrorEvent, New EventHandler(Of EditModeValidationErrorEventArgs)(AddressOf Me.ValidationError)))
            Me.XME.Style = style
        End Sub

     

    For your convenience, I created a small sample with a XamMaskedEditor having a ValueConstraint for values greater than 10. There is a button, which serves to lose focus of the editor and in case the value does not satisfy the constraint, the event, which is added with an EventSetter to the XamMaskedEditor’s Style property, is triggered when the button is clicked (and the editor has lost focus). You can find the sample attached below.

     

    If you require any further assistance on the matter, please let me know.

     

    Sincerely,
    Bozhidara Pachilova
    Associate Software Developer
Reply Children
No Data