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();
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.
//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


Popular posts from this blog

Clearcase check in/uncheck out all the checked out files script

Duplicating a local copy of project from TFS and making web software client factory to work