성태의 닷넷 이야기
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[정성태] Get Started with Milvus Vector DB i...
[정성태] cyberark/PipeViewer - A tool that...
[정성태] WinForms in a 64-Bit world – our st...
[정성태] 예제에서 SELECT_SQL도 내부적으로는 SqlCommand/...
[victor] SELECT_LINQ SELECT_SQL 같은 쿼리인...
[victor] 답변 갑사합니다. 예외(Exception)가 났습니다. ...
[정성태] 일단, 위의 방식대로 하면 예외(Exception) 없이 잘 동...
[정성태] Windows 10 (버전 1809)에 이런 기능이 ^^ 추가되...
[정성태] pde windbg extension ; https://lea...
[정성태] // GetEnumerator extensions for Ran...
글쓰기
제목
이름
암호
전자우편
HTML
홈페이지
유형
제니퍼 .NET
닷넷
COM 개체 관련
스크립트
VC++
VS.NET IDE
Windows
Team Foundation Server
디버깅 기술
오류 유형
개발 환경 구성
웹
기타
Linux
Java
DDK
Math
Phone
Graphics
사물인터넷
부모글 보이기/감추기
내용
<div style='display: inline'> <h1 style='font-family: Malgun Gothic, Consolas; font-size: 20pt; color: #006699; text-align: center; font-weight: bold'>WinForm 프로젝트를 WPF 프로젝트 유형으로 변경하는 방법</h1> <p> 사실 Visual Studio로 생성하는 모든 프로젝트들은 동일하게 XML 형식을 따르는 정보 파일이므로 서로 간에 변환이 가능합니다. 물론, 프로젝트 유형이 바뀌면 개별 프로젝트 형식에 맞는 소스 코드로 재구성해야 하는 것에는 변함이 없지만 그래도 기존 프로젝트를 그대로 유형만 바꾸도록 하는 것이 때로는 새롭게 프로젝트를 만드는 것보다 더 편리할 때가 있습니다.<br /> <br /> 이번 글에서는 Windows Forms 프로젝트를 WPF로 바꿔보겠습니다.<br /> <br /> 예제를 위해 간단한 윈폼 프로젝트를 만든 후, csproj 파일을 열어 ProjectTypeGuids 값을 다음과 같이 추가합니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > <ProjectTypeGuids>{<a target="_blank" href="https://www.codeproject.com/Reference/720512/List-of-Visual-Studio-Project-Type-GUIDs">60dc8134-eba5-43b8-bcc9-bb4bc16c2548</a>};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> C# Project - FAE04EC0-301F-11D3-BF4B-00C04F79EFBC WPF Project - 60dc8134-eba5-43b8-bcc9-bb4bc16c2548 </pre> <br /> 이어서 WPF 관련 어셈블리를 참조 추가하고,<br /> <br /> <ul> <li>PresentatioCore</li> <li>PresentationFramework</li> </ul> <br /> "User Control (WPF)" 유형으로 App.xaml 파일을 새롭게 추가한 다음, App.xaml 파일에 대한 속성 창에서 "Build Action" 값이 "Page"로 되어 있는 것을 "ApplicationDefinition"으로 변경합니다. 이어서 .xaml 파일과 .xaml.cs 파일을 각각 다음과 같이 변경해서 저장합니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > <Application x:Class="WindowsFormsApp1.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:WindowsFormsApp1" StartupUri="MainWindow.xaml"> <Application.Resources> </Application.Resources> </Application> </pre> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.IO; using System.Linq; using System.Windows; namespace WindowsFormsApp1 { public partial class App : Application { } } </pre> <br /> 위의 App.xaml.cs 코드에는 기존 WinForm 프로젝트의 Program.cs 파일에 여러분이 작성한 코드가 있다면 WPF 환경에 맞게 마이그레이션합니다. 완료되면 Program.cs 파일을 삭제합니다.<br /> <br /> 이제 남은 작업은 Form을 Window로 바꾸는 것입니다. "Window (WPF)" 유형으로 MainWindow.xaml을 추가하고 역시 여러분들의 기존 WinForm 프로젝트에 있던 메인 Form 관련 코드를 MainWindow로 마이그레이션합니다. 마찬가지로 나머지 Form 들도 모두 "Window (WPF)" 유형으로 마이그레이션한 다음 완료되면 기존 Form 들은 모두 삭제합니다.<br /> <br /> 이제 빌드하고 실행하면 다음과 같이 WPF 윈도우(MainWindow)가 뜨는 것을 확인할 수 있습니다. (물론, Form에 작성한 코드가 많다면 WPF로 옮기는 것이 쉽진 않을 것입니다.)<br /> <br /> <img alt='winform_to_wpf_1.png' src='/SysWebRes/bbs/winform_to_wpf_1.png' /><br /> <br /> (<a target='tab' href='http://www.sysnet.pe.kr/bbs/DownloadAttachment.aspx?fid=1215&boardid=331301885'>첨부 파일은 기본 Windows Forms 프로젝트를 WPF로 변경한 예제</a>입니다.)<br /> </p><br /> <br /><hr /><span style='color: Maroon'>[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]</span> </div>
첨부파일
스팸 방지용 인증 번호
8512
(왼쪽의 숫자를 입력해야 합니다.)