.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> ASP.NET Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Host the Windows form in the WPF application

Posted By:nishithraj       Posted Date: December 28, 2009    Points: 10    Category: ASP.NET Controls    URL: http://www.dotnetspark.com  

To host the Windows form in the WPF application first make sure to add references to System.Windows.Forms and System.Windows.Forms.Integration.
 

To host the Windows form in the WPF application first make sure to add references to System.Windows.Forms and System.Windows.Forms.Integration.


Following is the code to host the WinForm in the WPF application

WindowsFormsHost host = new WindowsFormsHost(); 

new System.Windows.Forms.Button(); 

"Host Windows Forms"; 

this.grid1.Children.Add(host); 

If you are using XAML, you still need to add the references as follows

 
"wf" ClrNamespace="System.Windows.Forms" Assembly="System.Windows.Forms"?> 
"AvalonApplication17.Window1" 
"http://schemas.microsoft.com/winfx/avalon/2005" 
"http://schemas.microsoft.com/winfx/xaml/2005" 
"wfi" 
"wf" 
"AvalonApplication17" 
"WindowLoaded" >

Now the XAML can be used to instantiate the WindowsFormsHost control and its subsequent child controls:

 
 
<"Windows Forms Button"/> 
 
 

 


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend