This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Windows Presentation Foundation In Windows Forms And Vice Versa
Brian NoyesChief ArchitectIDesign Inc (www.idesign.net)
2
About Brian• Chief Architect, IDesign Inc. (www.idesign.net) • Microsoft Regional Director/MVP• Writing
– Developing Applications with Windows Workflow Foundation, LiveLessons, June 2007
– Smart Client Deployment with ClickOnce, Addison-Wesley, Jan 2007– Data Binding in Windows Forms 2.0, Addison-Wesley, January 2006– MSDN Magazine, MSDN Online, CoDe Magazine, TheServerSide.NET,
asp.netPRO, Visual Studio Magazine• Speaking
– Microsoft TechEd, Visual Studio Connections, DevTeach, DevReach, INETA Speakers Bureau, MSDN Webcasts
• Participates in Microsoft Design Reviews• E-mail: [email protected]• Blog: http://briannoyes.net
hosts a single WPF Element• Typically a composite WPF control
– Provides rendering container for hosted WPF element within a Form/Control
– Hosting Windows Forms Control in WPF– Exposes properties to control the
presentation of the hosted element within the ElementHost container
10
Hosting WPF Controls In Windows Forms
• Create or obtain the WPF control• Create the Windows Forms host application• Add reference to the WindowsFormsIntegration assembly• Create an ElementHost control in the Windows Form• Create instance of WPF control• Set the WPF control as the Child of the ElementHost• Add the host to the Controls collectionfor the container
• Create or obtain the Windows Forms control• Create the WPF host application• Add reference to the WindowsFormsIntegration assembly• Add WindowsFormsHost control to window/page• Create instance of WinForms control• Set as Child of WindowsFormsHost• Add the host to the Children collection
Visual Studio Design-Time Support For Interop• Add WPF controls and element
host from designer– Toolbox item drag and drop– Some ElementHost properties
settable from designer– Contained control properties and
events not accessible from designer• Drop to code
• Windows Forms to WPF support – None
20
ResourcesWindows Presentation Foundation Unleashed, Windows Presentation Foundation Unleashed, Adam Nathan, Adam Nathan, SamsSams PublishingPublishing
Programming WPF, Programming WPF, Chris Sells and Ian Griffiths, AddisonChris Sells and Ian Griffiths, Addison--WesleyWesley
Windows Forms 2.0 Programming, Windows Forms 2.0 Programming, Chris Sells and Michael Chris Sells and Michael WeinhardtWeinhardt, Addison, Addison--WesleyWesley
Essential Windows Presentation Foundation, Essential Windows Presentation Foundation, Chris Anderson, AddisonChris Anderson, Addison--WesleyWesley