ElementHost 윈어플과 WPF 어플간의 컨트롤 사용
C# 에서 윈도우 어플리케이션과 WPF 어플리케이션 프로젝트 간의 컨트롤 교차 사용을 가능하게 하는 클래스.
간단히 설명하면..
예를 들면 WPF폼 위에 elementhost 개체를 올린후 그 위에 윈폼 컨트롤을 올리는 겁니다.
< 윈도우 어플에 WPF 컨트롤 >
유져컨트롤은 c# 에서 생성할 수 있는 클래스로 이 위에 WPF 개체가 올라가 있습니다.
ElementHost host = new ElementHost();
host.Dock = DockStyle.Fill;
// Create the WPF UserControl.
HostingWpfUserControlInWf.UserControl1 uc =
new HostingWpfUserControlInWf.UserControl1();
// Assign the WPF UserControl to the ElementHost control's
// Child property.
host.Child = uc;
// Add the ElementHost control to the form's
// collection of child controls.
this.Controls.Add(host);
<< WPF 에서 윈 컨트롤 사용>>
윈도우 xaml 애트리 뷰트에
xmlns:wf ="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
위와 같은 네임 스페이스 추가후..
윈폼호스트 개체를 올려 놓은후 이하 차일드로 C# 개체를 올려 놓습니다.
<WindowsFormsHost Name="hostWinForm" HorizontalAlignment="Right" Width="228.64" Height="168.75" VerticalAlignment="Top" Margin="0,55,20,0">
<wf:MonthCalendar Name="MCalendar" Dock="Left" DateChanged="MonthCalendar_DateChanged" ></wf:MonthCalendar>
</WindowsFormsHost>