기본 콘텐츠로 건너뛰기

2월, 2021의 게시물 표시

WPF Window Show / Close 후 새 Window Show 무시, 자동 종료 현상

 WPF 프로젝트 초기 개발시 Login 창 후 로직 처리 및 Main 창 호출이 되지 않고 종료 (exit code: 0) 되는 현상이 있습니다. 의도치 않은 기능인데, 아무래도 WPF 구조를 잘 모르는 상태에서 개발한 탓이겠지요. 개발 하고자 하는 흐름은 Application_Startup -> LoginWindow -> 비지니스 로직 -> MainWindow 인데, 비지니스 로직까지 돌고 바로 종료가 됩니다. app.xaml < Application  x : Class = "Test.App"               xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"               xmlns : x = "http://schemas.microsoft.com/winfx/2006/xaml"               xmlns : local = "clr-namespace:Test"               Startup = "Application_Startup" > 보통 저런 형태로 사용하는데 WPF 는 기본적으로 창이 없을 경우 자동으로 종료되는 기능이 있습니다. Application.ShutdownMode 속성 (System.Windows) | Microsoft Docs Application 속성에 보면 ShutdownMode 가 있습니다. < Application  x : Class = "Test.App"               xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"               xmlns : x = "http://schemas.microsoft.com/winfx/2006/xaml"               x