SWF in WPF application using WebBrowser

I needed a way to show SWF flash file inside an Windows Application, so i made this simple tutorial on how you can do it in Visual Studio.

First, create a new C# WPF Application:

createflashproject

Then, open MainWindow.xaml, and paste the following:

<Window x:Class="FlashInsideWebBrowser.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:FlashInsideWebBrowser" mc:Ignorable="d" Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded">
    <Grid>
        <WebBrowser Name="MySWFBrowser" HorizontalAlignment="Left" Margin="0" VerticalAlignment="Center" />
    </Grid>
</Window>

After this, open the code for MainWindow.xaml (in Solution Explorer window, right click MainWindow.xaml, and View Code) and paste this code:

using System;
using System.Windows;

namespace FlashInsideWebBrowser
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // fixes warning about ActiveX security
            string C_Drive_local = "file://127.0.0.1/c$/";

            // path of the flash file, here its in C:\DemoContent\bounce.swf
            Uri swfPath = new Uri( C_Drive_local + "DemoContent/bounce.swf");

            // load it in the browser
            MySWFBrowser.Source = swfPath;
        }
    }
}

Thats it, now Run the project, your flash file needs to run inside the application. Note that if you use the full windows style path, ex: @"C:\DemoContent\bounce.swf" you will have an security ActiveX prompt that tells you you need to Allow to run this kind of control and that its not safe, bla bla.

Here is how it looks in the end:

finallook