Home About Eric Topics SourceGear

2006-07-27 15:56:04

Serving WPF browser apps from Apache on Linux

I've been wondering if it's possible to serve a WPF browser application from my Linux box.  I found the answer on Lauren Lavoie's blog, but I just had to try it for myself.

So I added the following five lines to the appropriate VirtualHost section of my httpd.conf file:

AddType application/manifest .manifest
AddType application/xaml+xml .xaml
AddType application/x-ms-application .application
AddType application/x-ms-xbap .xbap
AddType application/octet-stream .deploy

Then I created a simple WPF browser and copied the resulting files up to my web server.  It worked!

Click here to try it out.  This is being served by Apache from my Linux server.  You'll need to have your desktop machine properly configured for running WPF applications.  This app was built with beta 2.

For those who want more details...

The source code for this simple xbap is here.  Here is how I created it:

  1. First I told Visual Studio to create a new "WinFX Web Browser Application".  (I'm still on beta 2, so I haven't made the name change to .NET 3.0 yet)
  2. Then I made several additions to Page1.xaml
    1. I added a label at the top so I would have a place to let the user know that the mouse does something.
    2. I added a toolbar so I would have a place to add a Print button.
    3. The ViewPort3D stuff is mostly copied from one of the WPF samples in the Windows SDK.
    4. The MeshGeometry3D data was the tricky part.  I hacked the solid modeling code in my woodworking app to output triangles in XAML and pasted the result in here.
  3. Finally, I made some additions to Page1.cs
    1. I added a handler for the Print button.
    2. I pasted in the trackball code from Daniel Lehenbauer.
    3. I added code to create a trackball and hook it up to the camera and the light.