Hosting WPF (Avalon Control) in WinForm quick info

Though this code snippet already available in the Win SDK sample.

//the host should be a private member variable.
ElementHost host = new ElementHosy();
host.Dock = DockStyle.Fill;
myPanel.Controls.Add(host); //adding the control the panel control in the winform.
//the variable datatype available after added reference
//to the WPF/Avalon control and WPF namespace)
avControl = new MyNamespace.MyAVControl();
avControl.InitializeComponent();
host.Child = avControl; //control has been linked to the winform

//The RoutedEventHandler is used because the WPF in this case is a
//child control. There are 3 type of event routing namely direct, tunnel and bubble.
//refer http://msdn2.microsoft.com/en-us/library/ms742806.aspx#why_use
//for more info on the event on WPF.
avControl.Loaded += new RoutedEventHandler(avCtrl_Loaded);

//To use Avalon control in Win32 which wrap the Avalon control into HwndSource
//refer http://blogs.msdn.com/nickkramer/archive/2005/07/17/439659.aspx

Comments

Popular posts from this blog

Outlook : "operation failed, object could not be found. " when trying to close a PST.

How to transfer app and data from old iPhone to new iPhone for model IOS17 and IOS18 above.

Troubleshooting Outlook Express (IMAP, POP3, HTTP, NEWS) with the log file