WPF 중복 창 방지

바위게·2024년 6월 21일

WPF

목록 보기
8/8
//xaml window
SettingWindow settingWindow;

//Button Command Function
public void GeneratePopUp(object obj)
        {
//그냥 싱글톤패턴 느낌으로 Null일때만 생성해주면 됨
            if (settingWindow == null)
            {
                settingWindow = new w_Setting(settingModel);
//Close Event를 할당해 창을 닫을때는 Null로 초기화
                settingWindow.Closed += (sender, e) => settingWindow = null;
            }            
            settingWindow.Focus();
            settingWindow.Show();
            settingWindow.Closed += SettingCloseEvent;
        }
profile
게임하는만큼만 개발공부하자

1개의 댓글

comment-user-thumbnail
2024년 9월 28일

ㅎ

답글 달기