Jpack
Jpack

Reputation: 1

Host WPF animation in Windows form

Project in visual studio 2010, can upgrade 2012 if need be. Want to animate my logo splash screen. I can do this using WPF. Can I host that WPF animation in a windows form in my vb.net visual studio project?

In Blend I create a new project and then a usercontrol in that project. Added logo images, animated and saved. I can bring that Blend project into my Visual Studio solution and referenced it, added the images as resources. I Created a panel on the form and in code created a new ElementHost and then set the usercontrol xaml file as the child in the splash screen load event. The Windows Form shows, but the images don’t and of course no animation. Can this even be done? If so, any guidance would be greatly appreciated.

Code:

Imports System.Windows.Forms.Integration
Public Class wpfSplash
    Public splashElementHost As New ElementHost
    Public Logo As New WpfControlLibrary1.ApplicationLogo.ctlLogo

    Private Sub wpfSplash_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        splashElementHost.Child = Logo
        splashElementHost.Location = New Point(13, 13)
        splashElementHost.Size = New Size(723, 644)
        pnlElementHost.Controls.Add(splashElementHost)
    End Sub
End Class

Upvotes: 0

Views: 624

Answers (1)

Halaster
Halaster

Reputation: 1502

If you're hosting a WPF application inside a WinForms Element Host you'll be limited by the WinForms rendering engine, so no, it can't be done.

Keep in mind that the animations being rendered by WPF have to be rendered again by WinForms afterwards, and it just can't handle animations. I found out the hard way, unfortunately.

Upvotes: 2

Related Questions