RepeatButton也是Buton其中的一種,主要的差別是在於當你按住RepeatButton不放的時候
,Click事件會被重複的觸發;下面是測試的程式碼,可以測試壓著Button不放的時候TextBox
的變化
RepeatButton也是Buton其中的一種,主要的差別是在於當你按住RepeatButton不放的時候
,Click事件會被重複的觸發;下面是測試的程式碼,可以測試壓著Button不放的時候TextBox
的變化
Imports System.Windows
Imports System.IO
Imports System.Reflection
Class Window1
Dim wp As WrapPanel
Dim txtInput As TextBox
Dim btnAdd As Windows.Controls.Primitives.RepeatButton
Private Sub Window1_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
wp = New WrapPanel
Me.Content = wp
txtInput = New TextBox
txtInput.Width = 200
txtInput.Text = "0"
wp.Children.Add(txtInput)
btnAdd = New Windows.Controls.Primitives.RepeatButton
btnAdd.Content = "Press Me"
wp.Children.Add(btnAdd)
AddHandler btnAdd.Click, AddressOf Button_OnClick
End Sub
Protected Sub Button_OnClick(ByVal sender As Object, ByVal e As RoutedEventArgs)
txtInput.Text = CInt(txtInput.Text) + 1
End Sub
End Class