Quantcast
Channel: Enter Button Behavior
Viewing all articles
Browse latest Browse all 5

Enter Button Behavior

$
0
0

Here's what I use:

Imports System.Windows.Interactivity

Namespace Behaviors

    Public Class TextBoxUpdateBehavior : Inherits Behavior(Of TextBox)

        Public Sub New()

        End Sub

        Protected Overrides Sub OnAttached()
            MyBase.OnAttached()
            AddHandler AssociatedObject.TextChanged, AddressOf AssociatedObjectOnTextChanged
        End Sub

        Private Sub AssociatedObjectOnTextChanged(sender As Object, args As TextChangedEventArgs)

            Dim bindingExpr = AssociatedObject.GetBindingExpression(TextBox.TextProperty)
            bindingExpr.UpdateSource()

        End Sub

        Protected Overrides Sub OnDetaching()
            MyBase.OnDetaching()
            RemoveHandler AssociatedObject.TextChanged, AddressOf AssociatedObjectOnTextChanged
        End Sub


    End Class

End Namespace

Graeme


Viewing all articles
Browse latest Browse all 5

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>