Browser based XBAP WPF applications
XAML Browser Applications (XBAP) :
XAML Browser Applications (XBAP) are Windows Presentation Foundation (.xbap) applications that are hosted and run inside a web browser. Like Web applications, XBAPs can be published to a Web server and launched from Internet Explorer. Like rich-client applications, XBAPs can take advantage of the capabilities of WPF. Developing XBAPs is also similar to rich-client development. Although one gets the perception of the application running in the browser, it actually runs in an out-of-process executable (PresentationHost.exe) managed by the CLR. In the initial release of .NET Framework 3.0, XBAPs only ran in Internet Explorer. With the release of .NET Framework 3.5 SP1 which includes an XBAP extension, they also run in Mozilla Firefox.XBAPs must execute within a partial-trust security sandbox that is restricted to the Internet zone permission set.
XBAP applications have certain restrictions on what .NET features they can use. Since they run in partial trust, they are restricted to the same set of permission granted to any InternetZone application. However 99% of standard WPF functionality is available to an XBAP application. Therefore most of the WPF UI features are available.
Permitted
• 2D drawing
• Can be run only in IE and Firefox.
• Newer versions are always installed automatically into the user's machine.
• User must be online to use the application.
• XBAP is Windows only. We can run the application in Windows operating system only.
• XBAPs cannot use WCF.
• The user machine should have .NET framework components
• 3D
• Animation
• Audio
• Calls to ASMX services.
• Calls to Windows Communication Foundation (WCF) services.
• Flow documents and associated readers.
• Internal drag and drop (mouse driven).
• MessageBoxes
• OpenFileDialog
• Pages
• Text Input controls (including RichTextBox).
• UI Controls
• Video
• XPS documents
Not permitted
• Access to OS drag-and-drop.
• Direct Database communication (unless application is fully trusted)
• Interoperability with Windows controls or ActiveX controls.
• Most standard dialogs.
• Shader Effects
• Stand-alone Windows.
Creating an XBAP Aplication :
To create an XBAP, follow these steps:
1. Open Visual Studio 2008 or Visual Studio 2010.
2. Click New, Project.
3. Select WPF Browser Application from the list of the projects.
4. Specify a name for the project and click OK. You'll see a screen like this one:
The WPF Browser Application creates different files one of them is page1.xaml. This is the page that will be displayed on the browser.
When application is compiled. This will create .xbap file inside the Debug folder in the project's \bin directory. When You run the application you will see the following
Deploying a XAML Browser Application :
When you build a XBAP, the Microsoft build engine (MSBuild) produces the following three files as a minimum:
An executable file. This contains the compiled code and has an .exe extension.
An application manifest. This contains metadata associated with the application and has a .manifest extension.
A deployment manifest. This file contains the information that ClickOnce uses to deploy the application and has an .xbap extension.
We can publish the XBAPs to a web server like IIS. We do not need to install .NET Framework in the web server. But you do need to register the WPF Multipurpose Internet Mail Extensions (MIME) types and file extensions. These are some MIME types which needs to be registered.
MIME Type | Extension |
application/manifest | .manifest |
application/x-ms-xbap | .xbap |
application/octet-stream | .deploy |
application/x-ms-application | .application |
application/vnd.ms-xpsdocument | .xps |
application/xaml+xml | .xaml |
To prepare your XBAP for deployment, copy the .exe and the associated manifests to your Web server. Create a hyperlink on a Web page to navigate to the deployment manifest. When the user clicks the link and navigates to the .xbap file, ClickOnce automatically handles the mechanics of downloading and launching the application.