wpf-browser-app

WPF Browser Application

WPF Browser applications (or XAML Browser applications, or XBAP) are a specific kind of application that are compiled into . xbap extensions and can be run in Internet Explorer.

XAML browser applications (XBAPs) combines features of both Web applications and rich-client applications. Like Web applications, XBAPs can be deployed to a Web server and started from Internet Explorer or Firefox on Windows. Like rich-client applications, XBAPs can take advantage of the capabilities of WPF. Developing XBAPs is also similar to rich-client development.

I am written this post because there are many application in WPF needs maintenance and further development. Today it is not needed to create a new project for WPF Browser because there has been come many new and modern technologies.

 

Creating WPF Browser Application Project

  1. Start Visual Studio 2022
  2. Select Create New Project and press to Next
  3. In Search area, Search for WPF Browser
  4. Select WPF Browser app (.NET framework) language C# or Vb.net here I am taking vb.net (Visual Basic) and press Next
  5. give a name for project and location, and  pre.NET framework version (I am taking 4.8.1),  press to Create button.
  6. The WPF Designer for Visual Studio opens and displays Page1.xaml of the project.
  7. project is created as shown in the following figure:

wpf-browser-app-1.png

As seen in the above figure, there is a .xaml file (Page1.xaml) and a .vb.net file (Page1.xam.vb). .xaml file is Source code for xaml code and .vb code is Vb.net code for implementation of xaml.

Open Toolbox and drag and drop UI controls like:  Textbox and a Button controller to XAML UI and implement them in the VB.net (.vb) code file.

Under bin the files. wpfBrowserapp1.exe (application) and wpfBrowserapp1.xbap (xaml browser application) and other files are created.

Obs! You can’t run this application in Windows 10 or 11, because you need IE or Firefox which is not supported by Windows 10 or higher.

Important: XBAPs require legacy browsers to operate, such as Internet Explorer and Firefox. These older browser versions are usually unsupported on Windows 10 and Windows 11.

Deploying an XBAP

When you build an XBAP, the output includes the following three files:

File Description
Executable (.exe) This contains the compiled code and has an .exe extension.
Application manifest (.manifest) This contains metadata associated with the application and has a .manifest extension.
Deployment manifest (.xbap) This file contains the information that ClickOnce uses to deploy the application and has the .xbap extension.

You deploy XBAPs to a Web server, for example Microsoft Internet Information Services (IIS) 5.0 or later versions. You do not have to install the .NET Framework on the Web server, but you do have to register the WPF Multipurpose Internet Mail Extensions (MIME) types and file name extensions.

To prepare your XBAP for deployment, copy the .exe and the associated manifests to the Web server. Create an HTML page that contains a hyperlink to open the deployment manifest, which is the file that has the .xbap extension. When the user clicks the link to the .xbap file, ClickOnce automatically handles the mechanics of downloading and starting the application. The following example code shows an HTML page that contains a hyperlink that points to an XBAP.

<html>
    <head></head>
    <body>
        <a href="XbapEx.xbap">Click this link to launch the application</a>
    </body>
</html>

you can also host an XBAP in the frame of a Web page. Create a Web page with one or more frames. Set the source property of a frame to the deployment manifest file. If you want to use the built-in mechanism to communicate between the hosting Web page and the XBAP, you must host the application in a frame. The following example code shows an HTML page with two frames, the source for the second frame is set to an XBAP.

<html>
    <head>
        <title>A page with frames</title>
    </head>
    <frameset cols="50%,50%">
        <frame src="introduction.htm">
        <frame src="XbapEx.xbap">
    </frameset>
</html>

For more info look here

Conclusion

In this post, I have explained , WPF Browser application and how to create it via Visual Studio. Application can be started via browsers like IE (Internet Explore). Windows 10 doesn’t support IE. WPF Browser app can be deployed to a Web Service like IIS.

My next post is about MVVM(Model-View-ViewMold) Pattern and using it in the WPF to separate UI from code logic.

This post is part of “WPF step by step”

 

Back to home page

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *