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





Wednesday, June 13, 2007 4:27:53 PM (GMT Standard Time, UTC+00:00)
Comments [2]  | 

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





Wednesday, June 13, 2007 4:25:05 PM (GMT Standard Time, UTC+00:00)
Comments [2]  | 

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





Wednesday, June 13, 2007 2:38:35 PM (GMT Standard Time, UTC+00:00)
Comments [0]  | 

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



.NET | .NET 3.0 | Speaking

Wednesday, June 13, 2007 1:05:36 AM (GMT Standard Time, UTC+00:00)
Comments [2]  | 


  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...



.NET | Languages and Tools

Monday, April 30, 2007 6:10:48 PM (GMT Standard Time, UTC+00:00)
Comments [1]  | 


  Saturday, April 28, 2007

Great guidance on using Team Foundation Server for your projects
Some articles on employing VSTS/TFS correctly for your team

.NET | Languages and Tools

Saturday, April 28, 2007 12:24:41 PM (GMT Standard Time, UTC+00:00)
Comments [0]  | 


  Monday, March 26, 2007

DevConnections Orlando - a tale of three sessions
A quick ditty on what sessions I'm presenting at DevConnections this week. Expect sample code in a couple days.

.NET | .NET 3.0 | DevConnections | Speaking

Monday, March 26, 2007 10:43:18 PM (GMT Standard Time, UTC+00:00)
Comments [7]  | 


  Tuesday, March 20, 2007

The WPF Book You Can't Live Without - WPF Unleashed
A quick gushing review of Adam Nathan's WPF Unleashed

.NET | .NET 3.0 | Publishing

Tuesday, March 20, 2007 9:48:11 PM (GMT Standard Time, UTC+00:00)
Comments [5]  | 


  Tuesday, March 13, 2007

ClickOnce Community Resource Kit has found a new home
ClickOnce guidance has moved to CodePlex, here are the URLs

.NET | ClickOnce | Community | Languages and Tools

Tuesday, March 13, 2007 11:10:10 AM (GMT Standard Time, UTC+00:00)
Comments [1]  | 


  Monday, March 12, 2007

Hands on WPF - dnrTV - Part 1
WPF episode on dnrTV available

.NET | .NET 3.0 | Languages and Tools

Monday, March 12, 2007 12:24:02 PM (GMT Standard Time, UTC+00:00)
Comments [0]  | 


  Saturday, February 17, 2007

NOVA / DC Area Code Camp
NOVA Code Camp coming in April

.NET | .NET 3.0 | Architecture | Community | Speaking

Saturday, February 17, 2007 1:47:42 AM (GMT Standard Time, UTC+00:00)
Comments [0]  | 





















Sign In
Copyright © 2006-2007 Brian Noyes. All rights reserved.
designed by NUKEATION STUDIOS