|
Thursday, July 27, 2006
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:
- 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)
- Then I made several additions to Page1.xaml
- I added a label at the top so I would have a place to let
the user know that the mouse does something.
- I added a toolbar so I would have a place to add a Print
button.
- The ViewPort3D stuff is mostly copied from one of the WPF
samples in the Windows SDK.
- 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.
- Finally, I made some additions to Page1.cs
- I added a handler for the Print button.
- I pasted in the trackball code from Daniel Lehenbauer.
- I added code to create a trackball and hook it up to the
camera and the light.
|