This is a mirror of official site: http://jasper-net.blogspot.com/

Things to consider when building a browser-based WPF application

| Thursday, May 26, 2011
Although WPF browser-based applications are not that popular with the growing interest in Silverlight, HTML5 and JavaScript (yes, I said JS), those still have a niche due to the capabilities offered by them. Not many developers know that the advantage of XBAP (WPF browser-based) applications is the fact that it is possible to directly invoke OS calls from the application that runs in the browser. Although with great power comes great responsibility, it is very possible to use XBAP apps in a much broader context compared to standard Silverlight applications.

So here are some points to remember when developing XBAP applications.

Full trust apps will require a certificate

In order to be able to access the OS capabilities (even components like the WebBrowser) will require the application to have a certificate installed on every client machine. This is not that big of an issue if the application is used internally, where people can set a specific security level and installing an internal certificate is not a problem. For external applications, users might be a bit hesitant if the certificate comes outside the trusted zone.

The default certificate that is assigned to an application will not be enough because it is assigned to a test machine and will only work for a short period of time. The solution here is to generate your own certificate and make it available to users who will use the app. Instructions on how to do this are available here.

Make sure that you re-size the application properly

When the application runs inside the browser, you never know what size it will have. That being said, implement  a simple re-sizing mechanism. For example, in one of the applications I was working on I did this:

The Page (content host) has no explicit size limits defined.
Using a Canvas control instead of the default Grid to define the page layout.
When the page is resized, I am handling this in the SizeChanged event handler:

this.SizeChanged += new SizeChangedEventHandler(Page1_SizeChanged);

The internals of the event handler look like this:

void Page1_SizeChanged(object sender, SizeChangedEventArgs e)
{
WHost.Height = this.ActualHeight;
WHost.Width = this.ActualWidth;
}

Here, WHost is a control inside the Canvas.

Be ready for deployment nuances
This is mainly tied to the fact that deployment is done through ClickOnce. Also, another important requirement for an XBAP application is the presence of .NET Framework 3.0 on the client machine. This might become a serious roadblock on *nix and Mac machines. That being said, Silverlight is less restrictive in this context, but some features will be removed (e.g. native access to the OS).

IE doesn't "like" XBAP applications by default. Other browsers - not so much, either.

Read more: .NET Zone

Posted via email from Jasper-net

0 comments: