I use the dispatchtimer with wpf applications. Here a short example.
Rename Window to MainWindow, add a checkbox.
Class Window1
Dim WithEvents MyTimer As New System.Windows.Threading.DispatcherTimer
Dim n As Integer = 0
Private Sub CheckBox1_Checked(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles CheckBox1.Checked, CheckBox1.Unchecked
' Combined Checked and UnChecked event.
If CheckBox1.IsChecked Then
MyTimer.Start()
Else
MyTimer.Stop()
n = 0
End If
End Sub
Private Sub MyTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyTimer.Tick
n += 1
MainWindow.Title = n.ToString
End Sub
Private Sub MainWindow_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles MainWindow.Loaded
MyTimer.Interval = New TimeSpan(500000) ' 50 ms, 100 ns/bit
End Sub
End Class
Note also how to handle the Checkbox Check event, there is no CheckChanged event in wpf.
In Windows Form Application you write like below:
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked Then
' To something when checked....
Else
' To something when unchecked....
End If
End Sub
In wpf you have to combine two events, .Checked and .Unchecked. The property .Checked is in wpf replaced with .IsChecked.
Friday, April 30, 2010
Subscribe to:
Posts (Atom)
MySQL to MariaDB
Here is a good description how to migrate to MariaDb MySQL to MariaDb Example of how to dump data from MySQL port=3307: mysqldump --user=ro...
-
When converting an VB2008 application to VB2010 I run into trouble regarding COM objects while compiling. you get errors like: Error 1...
-
In a module you have declared a Structure or Enum that you will use through out a project. Module Module1 Public Structure dummy ...
-
Apache2 crashes on Ubuntu Linux 22.04.5 after Zabbix was updated to 7.0.26 During a upgrade of my Ubuntu server there was a new package for ...