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

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

MSSQL GROUP_CONCAT

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