Supporting WPF XML Browser Applications (XBAP) in a CompositeUI Application Block application
Currently, we’re building a real application in WPF for a local government. The application uses the MVC pattern quite heavily, so I did a test to see whether we could use the Composite UI Application Block (CAB, read more about it’s architecture and use, download it from MSDN, play with the labs to understand it) to enable easier composability in order to distribute our use cases more easily throughout the development team, decouple logic from UI even more, etc.
It turns out the CAB currently doesn’t support WPF. After some searching, I discovered Kent Boogaart from Australia (thanks Dion!) is busy writing a support layer for WPF in CAB. So far, so good. Testing the download he provided, however, revealed the implementation doesn’t support so-called XBAP applications.
XBAP application are browser hosted WPF applications and are different in some aspects to ‘traditional’ WPF applications. For instance, the Application object which is the root for all WPF applications, doesn’t allow you to call the Run method if the WPF application is running within a browser. This is because of the asynchronous nature of the webbrowser.
After a few simple modifications to Kent’s code and a little more trickery, I had the BankTeller application working in XBAP. Well, sort of… The thing with CAB is that it assumes synchronous applications. An example of this (taken straight from Microsoft.Practices.CompositeUI.CabApplication):
As I explained earlier, XBAP applications take offense to calling the Run method on their Application, they’re asynchronous. In order to make XBAP applications work, a few modifications have to be made to CAB itself.
If you’re interested in more detail about the changes I made and how I did this, please read the whitepaper I wrote, which can be downloaded here.
A special thanks to Kent Boogaart for creating the WPF port for CAB, without which I wouldn’t have been able to put CAB to use in my WPF scenario!
It turns out the CAB currently doesn’t support WPF. After some searching, I discovered Kent Boogaart from Australia (thanks Dion!) is busy writing a support layer for WPF in CAB. So far, so good. Testing the download he provided, however, revealed the implementation doesn’t support so-called XBAP applications.
XBAP application are browser hosted WPF applications and are different in some aspects to ‘traditional’ WPF applications. For instance, the Application object which is the root for all WPF applications, doesn’t allow you to call the Run method if the WPF application is running within a browser. This is because of the asynchronous nature of the webbrowser.
After a few simple modifications to Kent’s code and a little more trickery, I had the BankTeller application working in XBAP. Well, sort of… The thing with CAB is that it assumes synchronous applications. An example of this (taken straight from Microsoft.Practices.CompositeUI.CabApplication):
public void Run()
{
RegisterUnhandledExceptionHandler();
Builder builder = CreateBuilder();
AddBuilderStrategies(builder);
CreateRootWorkItem(builder);
...
rootWorkItem.FinishInitialization();
rootWorkItem.Run();
Start();
// Whoops for non-blocking Start()s
rootWorkItem.Dispose();
if (visualizer != null)
visualizer.Dispose();
}
As I explained earlier, XBAP applications take offense to calling the Run method on their Application, they’re asynchronous. In order to make XBAP applications work, a few modifications have to be made to CAB itself.
- Don’t call Run on the Application class.
- Ensure the correct UI element get’s displayed.
- Remove the dispose calling from the main Run() method of Microsoft.Practices.CompositeUI.CabApplication.
- Implement a correct IDisposable pattern for cleaning up resources once the Application is actually done with them.
- Ensure we call Dispose to clean up used resources.
If you’re interested in more detail about the changes I made and how I did this, please read the whitepaper I wrote, which can be downloaded here.
A special thanks to Kent Boogaart for creating the WPF port for CAB, without which I wouldn’t have been able to put CAB to use in my WPF scenario!
10 Comments:
Hi, I just can't download the zip file and doc file, can't you mail me a copy thnak you.
isurge@msn.com
By Anonymous, at 12:32 PM
Hi Martijn,
I would really like to download your whitepaper and source code, but the links are broken.
If you cannot publish those files, could you please e-mail them to sjappelodorus at hotmail?
Thanks in advance!
By Anonymous, at 1:30 PM
I would like to download your whitepaper and source code too, but I can't. Can you send me a e-mail with them to wangyangui@gmail.com?
Thanks a lot.
By Unknown, at 5:07 PM
Hi
I will be starting a new project in WPF soon and I'm thinking about using the CAB. I found you via Kent's blog and I see you were also trying to use his library. So my question is whether you finally decided to use it and how does it work? If not what did you use instead?
By Szymon, at 9:28 AM
E-stores are in demand as the lives of people are getting more hectic everyday. But keep in mind; you must be able to realize your exact requirement to know the
right http://www.infysolutions.com ecommerce solution you need and it can bring fortune to you for sure. Understand the need, Get the best fit solution and grab the benefits of living in ecommerce era!
By Anonymous, at 12:17 PM
Phone Shop
Bestsellers Book
Women's Shoes
Top10 List Bestsellers Book
adidas online store
Health Insurance
Auto Repair Manual
By Anonymous, at 7:50 PM
Interesting thoughts here. I appreciate you taking the time to share them with us all. What a great website, I am happy I found it.
By Phones by Brand, at 6:21 PM
Simply, admirable what you have done here. It is pleasing to look you express from the heart and your clarity on this significant content can be easily looked. Remarkable post and will look forward to your future update...
cerita dewasa foto bugil bokep 3gp gambar bugil cewek bugil
By cerita dewasa, at 11:44 AM
Thanks you. Very good post.Unless they can offer a really compelling reason for users to come back, it will be the next Bebo, MySpace
By Gadgets UK, at 9:45 AM
Thanks you. Very good post.Unless they can offer a really compelling reason for users to come back, it will be the next Bebo, MySpace
By 10755GF, at 11:08 PM
Post a Comment
<< Home