Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using XAML in WinForms

Tags:

winforms

xaml

I want to use XAML to generate classes at compile time in a complete WinForms app. I don't want to use WPF although I am open to suggestions.

It seems like this should be possible but I can't find any information about exactly how. The closest thing I've found is this page: http://anoriginalidea.wordpress.com/2007/12/13/weird-science-defining-winforms-in-xaml/

Any ideas?

like image 905
smack0007 Avatar asked Nov 08 '10 19:11

smack0007


People also ask

Can I use XAML in Windows Forms?

Hosting the Windows Forms Control xaml in the WPF Designer. In the Window element, add the following namespace mapping. The wf namespace mapping establishes a reference to the assembly that contains the Windows Forms control. In the Grid element add the following XAML.

Can you mix WPF and WinForms?

Yes you can, both Windows Forms within a WPF application, and WPF controls within Windows Forms.

Can you use WPF controls in WinForms?

Add a WPF control to a Windows Form Your new WPF control is ready for use on the form. Windows Forms uses the ElementHost control to host WPF content. To add a WPF control to a Windows Form: Open Form1 in the Windows Forms Designer.


1 Answers

It's a common misconception that XAML = WPF, it doesn't. I'd suggest looking at CODE + MARKUP = Applications book by Petzold. Though I suspect that it won't cover Winforms per se. I've always planned to try this but never got round to it. Good luck.

like image 182
Preet Sangha Avatar answered Oct 05 '22 15:10

Preet Sangha