Bonjour,
J'aimerai utiliser le Control Timer sur un programme WPF. Ce control n'existe pas et j'aimerai faire fonctionner un ProgressBar Control.
Comment faire ?
Merci.
Version imprimable
Bonjour,
J'aimerai utiliser le Control Timer sur un programme WPF. Ce control n'existe pas et j'aimerai faire fonctionner un ProgressBar Control.
Comment faire ?
Merci.
il y a des timers dans le framework dont un dans system.timers
un timer n'est pas un control
J'ai opté pour ce code :
Le problème c'est au niveau de cette ligne (je crois):Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 Private Sub Window1_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded animation() End Sub Private Delegate Sub upbd(ByVal dp As System.Windows.DependencyProperty, ByVal value As Object) Private Sub animation() ProgressBar1.Minimum = 0 ProgressBar1.Maximum = Short.MaxValue ProgressBar1.Value = 0 Dim value As Double = 0 Dim upd As New upbd(AddressOf ProgressBar1.SetValue) Do Until ProgressBar1.Value = ProgressBar1.Maximum value += 1 Dispatcher.Invoke(upd, System.Windows.Threading.DispatcherPriority.Background, New Object() {ProgressBar.ValueProperty, value}) Loop End Sub
Cela permet au ProgressBar de se charger, mais quand j'essai de compiler et d'exécuter mn programme je ne vois rien du tout (la fenêtre ne s'affiche pas mais elle reste sur la barre des tâches) jusqu'à ce que le progressbar complète son travail (c'est là où ma fenêtre s'affiche).Code:
1
2 Dispatcher.Invoke(upd, System.Windows.Threading.DispatcherPriority.Background, New Object() {ProgressBar.ValueProperty, value})
J'espère que j'étais clair :lol:
C'est un DispatcherTimer que je dois utiliser car il est l'équivalent de Timer sur WPF.
Merci Pol63 pour ton aide.:ccool: