Forms & WPF integration

Forms & WPF integration

Old forum URL: forums.lhotka.net/forums/t/4058.aspx


ajj3085 posted on Tuesday, December 18, 2007

Hi,

I'm trying to get some WPF into my project, which right now is a forms project.  To do so, I'm creating a WPF user control which will be hosted on one of my forms.  I'd like to know if there will be any problems mixing the two. 

Has anyone attempted doing this?  Will Csla handle this scenario?

RockfordLhotka replied on Tuesday, December 18, 2007

Beats me, sorry... I look forward to hearing how this works out Smile [:)]

Massong replied on Wednesday, December 19, 2007

Hi Andy,

I’m very interested in your experiences. Sooner or later I want to upgrade our existing Windows Forms application, too. Does WPF mean that we have to rewrite our complete GUI or will be a migration tool available? If not, we can do the upgrade only step by step.

I’m waiting for some forthcoming books about VS 2008, especially Matthew MacDonald’s book about WPF. And I’m waiting for our third party controls developer and their WPF grid control.

Greetings,
Christian

PS: Can you recommend any books that are already available?

RockfordLhotka replied on Wednesday, December 19, 2007

Andy was specifically asking about using “Crossbow” to mix WPF and Windows Forms in a single app.

 

If you are looking at creating a WPF interface, that’s certainly approachable. The answers to your questions though, are Yes and No. Yes you’ll need to rewrite your GUI, and no there are not migration tools. I doubt there will be migration tools, because the architecture of WPF is so different from Windows Forms or Web Forms that I can’t see how you could automate the process…

 

Right now the best books appear to be Chris Anderson’s “Essential Windows Presentation Foundation” and Adam Nathan’s “Windows Presentation Foundation Unleashed”.

 

Rocky

 

From: Massong [mailto:cslanet@lhotka.net]
Sent: Wednesday, December 19, 2007 7:07 AM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] Forms & WPF integration

 

Hi Andy,

I’m very interested in your experiences. Sooner or later I want to upgrade our existing Windows Forms application, too. Does WPF mean that we have to rewrite our complete GUI or will be a migration tool available? If not, we can do the upgrade only step by step.

I’m waiting for some forthcoming books about VS 2008, especially Matthew MacDonald’s book about WPF. And I’m waiting for our third party controls developer and their WPF grid control.

Greetings,
Christian

PS: Can you recommend any books that are already available?



ajj3085 replied on Wednesday, December 19, 2007

Basically, what Rocky said.  I have a control I want to create because it would allow a better user experience, so I'm creating a WPF user control within a windows forms application.  If it does well, I may in fact create more and more controls, until I basically have WinForms hosting an entire page.  At that point, there's some manual tweaking you can do in the project file to make the project offically a WPF application.

That's my plan.  It will take a while though.  I haven't gotten any books yet, but I'm going to look at the ones Rocky suggests.

I'm starting off very small though; I won't be doing direct data-binding per-say.  I'll be passing the control a BusinessListBase subclass of objects, which will render in a ComboBox.  When one is selected, the control will raise an event and pass the selected object as part of the event arguments. 

Why am I doing it like this?  Well, its similar to how another WinForms control I built works, where the user must select an address from a list of existing addresses, OR pick the "empty" address to type in an address which doesn't exist.  I'm doing something similar for phone and fax numbers (pick an existing one, or type in a new one), and so far WPF is easier than the controls I had to build to make the address selector work.

I do hope to do more though, as I want to do new development in WPF, using Crossbow to embed WPF into a form host.

Massong replied on Wednesday, December 19, 2007

Thanks Rocky and Andy for your reply.

I think I saw a presentation of WindowsFormsHost to use Windows Forms controls in WPF a year ago. "Crossbow" would be the other direction, using WPF in a Windows Forms application? Thank you for this hint. I could start with upgrading selected User Controls and use them in my forms (Like Andy says). Upgrading the forms themselves would be the last step, because I inherited all my dialog forms from a extended base class.

At Andy: Why is WPF easier to use than Windows Forms? I saw some presentations of WPF that focused on the better layout, 3D, Vista, and user experience. But I've never thought it would be easier to use...

Massong replied on Wednesday, December 19, 2007

Sorry, my misunderstanding: You mean that the control is not easier to build but it has got a better usability...?

csanchez replied on Wednesday, December 19, 2007

Hi:

I think is the other way around. WindowsFormsHost is for hosting a form's control in WPF. You might be reffering to a ElementHost which you use to host a WPF control in a Windows Form enviroment.

I haven't tried the last one, but the WindowsFormsHost is working great in my project.

Christian.

ajj3085 replied on Wednesday, December 19, 2007

Well, Crossbow is mostly hidden I think.  There's a control in the toolbox which is System.Windows.Forms.Integration.ElementHost, which acts as the host for the control.  So far, very simple.

WPF is easier because, well, I don't need to write a ton of code to put a couple of text boxes on each ComboBoxItem.  With WinForms, I'd probably have to code almost from scratch.  Wpf lets controls contain other controls.. so no need to do this.

Of course not knowing much about WPF is slowing me down a bit, but that's just because I haven't learned it yet.

Copyright (c) Marimer LLC