Hi guys, I want to add an animated taskbar icon to my WPF project. I figured I would just use the Icon property, but I'm fairly new to WPF, and I dont know how to do it. In Winforms I would create a thread like this:

Private Sub AniIcon()
Do
'I split a gif into its individual frames and then load them sequentially
Me.Icon = Image.FromFile("Path\to\split\GIF\here") 
System.Threading.Thread.Sleep(250)
Loop
End Sub

But I can't find a Window.Dispatcher to use this approach in WPF. I also see something about "BeginAnimation" in the Icon Property?

So, what is the best way to do this?

Well I'm not too familiar with .NET but you can set up a timer component to call each frame of your animation. Just make sure each one is in the resources of your application.

PSEUDO CODE:

If form1.icon = frame1.jpg Then
form1.icon = frame2.jpg
End If

Else If form1.icon = frame2.jpg Then
form1.icon = frame3.jpg
End If

Else If form1.icon = frame3.jpg Then
form1.icon = frame1.jpg
End If

This should be on a timer tick event, it's a pseudo code so you'll have to switch it up to the actual syntax. I'm not sure what it is in .NET I'm a C# and C++ programmer lol but the pseudo should help a little.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.