본문 바로가기
Windows/C#/WPF

WPF 에서 WinForm 컨트롤을 생성하는 방법

by hirudev 2021. 5. 1.
※ 해당 글은 https://docs.microsoft.com/ko-kr/dotnet/desktop/wpf/advanced/walkthrough-hosting-a-windows-forms-control-in-wpf?view=netframeworkdesktop-4.8 을 참고하였습니다.
// WinForm Host 를 생성
System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost();
// 호스트 설정
host.Width = 100;
host.Height = 25;

// 버튼 컨트롤을 생성
System.Windows.Forms.Button btn = new System.Windows.Forms.Button();
btn.Text = "test";

host.Child = btn;

// WPF 현재 윈도우에 host 를 하나의 컨트롤로써 등록.
this.AddChild(host);

'Windows > C#/WPF' 카테고리의 다른 글

Property resource 로 등록된 이름을 불러오는 방법  (0) 2021.05.04
WPF Control  (0) 2021.05.02
레이아웃 종류  (0) 2021.05.01
Object 요소 property  (0) 2021.05.01
XAML 의 로드  (0) 2021.04.30

댓글