Wednesday, June 13, 2007
TechEd Session: WPF/Windows Forms Hybrid Applications
My second TechEd breakout session was in the Developer tools track (DEV340). This talk covered the interop story between Windows Forms and WPF and showed how to put WPF controls in a Windows Forms application, and Windows Forms controls in a WPF application.
For WPF in a Windows Forms app, it boils down to 4 lines of code:
- Create an ElementHost control
- Create the hosted WPF control
- Add the ElementHost control to a container in the Windows Forms app
- Set the Child property of the ElementHost to point to the hosted control instance
This looks like the following:
ElementHost host = new ElementHost(); MediaElement mediaEl = new MediaElement(); panel1.Controls.Add(host); host.Child = mediaEl;
You will also need to add a reference to WindowsFormsIntegration.dll and add a using statement for the System.Windows.Forms.Integration namespace, as well as a reference and using statement for the namespace of the WPF control that you are hosting (System.Windows.Controls in this case for the MediaElement control). You will also likely want to set the Dock property of the host control to Fill its container, and may want to keep the references for the host and the hosted control around in member variables on the form so that you can access them from event handlers and such.
To go the other way, it is the same basic process, but the host control is a WindowsFormsHost instead of ElementHost.
There are also a number of interop challenges you will face, which I covered in the talk, and showed how to overcome some of those challenges through property maps.
Finally, I demonstrated that in VS 2008, you can drag and drop WPF controls onto a Windows Form, and the ElementHost will be added and configured for you (basically it writes those four lines of code for you.
You can download the slides and demos for this session here: Slides Demos
TechEd Session: Deploying Smart Client Architectures
One of my breakout sessions at TechEd last week was ARC304: Deploying Smart Client Architectures. The talk covered what the options are for deploying both the client and server side artifacts in a smart client architecture, and spent most of the time discussing these things with respect to ClickOnce as a smart client technology. I covered how ClickOnce works at a high level, then dove into what is going on behind the scenes, how the manifests drive the show, what you need to put where in your server side architecture for publishing a smart client, and then what ends up where after deployment on the client side. One the options side, it really boils down to the following: - ClickOnce - best choice for most .NET 2.0 and later smart client apps (or even prior using some tricks outlined in my book), but only affects deploying client side application and components that are not system wide.
- Updater Application Block - still a good option for automatic or on-demand update of client side (or even server side) components, allows a lot more flexibility in performing custom install steps during the update process, but requires more work to integrate with your application. Also does not address initial deployment in any way.
- Windows Installer (MSI) - not going anywhere. Still appropriate for heavyweight client side installs that affect system-wide settings or directories, and the primary choice for deploying server side components.
I won't try to summarize all the ClickOnce stuff I covered, that has all been addressed in various previous blog posts on my blog as well as in my book. Slides and demos here: Slides Demos
Using Live Writer to publish blog posts
At the recommendation of some really smart people (Scott Hanselman and Richard Campbell specifically), I've decided to start using Microsoft Windows Live Writer to author my blog posts. This nice little tool lets you author your posts offline in a smart client WYSIWYG editor. Its available at http://writer.live.com
Slides and demos from Cleveland .NET SIG
I gave a talk on WPF for ASP.NET developers this evening at the .NET SIG in Cleveland. Good size crowd and great questions. It was a challenging talk because of trying to cover all of WPF and Silverlight for ASP.NET developers and for those in the crowd who were Windows Forms developers.
I covered the various deployment models of WPF including:
- Windows Application
- XAML Browser Application (XBAP)
- Plain Old XAML Page (POXP?)
- Silverlight App
Whenever I present this stuff, the overwhelming reaction is: Stop giving us so many choices!!! We can't figure out what to use when!
There is also often a desire for a conclusion to be drawn that one of these will be the end state and all UI will be written in it. I just don't think that will be the case. I think that maybe 5 years from now, if the tools come along a lot farther than they are now, and if the control suite grows, the list of options could shorten to just WPF Windows App, Silverlight App, and ASP.NET AJAX app. But I don't think it will shrink beyond that. Windows Apps make sense when you control the desktop to take maximum advantage of the client platform and give the best user experience. Silverlight makes sense for broader reach while sticking to the same tools and programming models. ASP.NET AJAX will be broader still and will address the platforms that Silverlight can't reach, and will also (like Windows Forms) be more evolved for data over forms apps for a while to come.
Anyway, here are the slides and demos for those who are interested:
Slides Demos
Monday, April 30, 2007
Silverlight - not just pretty graphics - Cross platform .NET Framework!
Watching Scott Guthrie's keynote at Mix07 right now. The word is finally out - and wow. Silverlight is not just a Flash alternative - it is a cross platform, cross browser .NET runtime and framework. C#, VB, any .NET language driving display in the browser, running on the client side, on other platforms.
Beta for 1.0 is out today, available on www.silverlight.net.
You can even debug cross platform with the .NET code running in a Mac browser. I think we are not far from stepping through the time space continuum now...
Saturday, April 28, 2007
Monday, March 26, 2007
Tuesday, March 20, 2007
Tuesday, March 13, 2007
Monday, March 12, 2007
Saturday, February 17, 2007
|







| July, 2008 (1) |
| June, 2008 (2) |
| May, 2008 (2) |
| April, 2008 (3) |
| February, 2008 (6) |
| January, 2008 (3) |
| December, 2007 (1) |
| November, 2007 (1) |
| October, 2007 (5) |
| September, 2007 (1) |
| July, 2007 (3) |
| June, 2007 (8) |
| April, 2007 (2) |
| March, 2007 (4) |
| February, 2007 (1) |
| December, 2006 (2) |
| November, 2006 (9) |
| October, 2006 (5) |
| September, 2006 (3) |
| August, 2006 (2) |
| July, 2006 (4) |
| June, 2006 (5) |
| May, 2006 (10) |
| April, 2006 (4) |
| March, 2006 (2) |
| February, 2006 (12) |
| January, 2006 (7) |
| December, 2005 (2) |
| November, 2005 (15) |
| October, 2005 (6) |
| September, 2005 (7) |
| August, 2005 (3) |
| July, 2005 (10) |
| June, 2005 (11) |
| May, 2005 (7) |
| April, 2005 (8) |
| March, 2005 (6) |
| February, 2005 (2) |
| January, 2005 (6) |
| December, 2004 (3) |
| November, 2004 (5) |
| October, 2004 (2) |
| September, 2004 (5) |
| August, 2004 (13) |
| July, 2004 (6) |
| June, 2004 (14) |
| May, 2004 (17) |
| April, 2004 (12) |
| March, 2004 (8) |
| February, 2004 (10) |
| January, 2004 (14) |
| December, 2003 (9) |
| November, 2003 (13) |
| October, 2003 (3) |


Sign In
|