Aytaç Aşan
Aytaç Aşan

Reputation: 165

How can I handle closing event of popup window's wrapper window?

I'm showing some content to user via popup window. Popup window's view model has a "CloseWindowCommand" and it's method as follows;

    private void CloseWindow()
    {
        var codeFileViewModels = CodeFileViews.Select(view => GetCodeFileViewModel(view)).Where(viewModel => viewModel.IsDirty);
        foreach (var codeFileViewModel in codeFileViewModels)
        {
            _regionManager.RequestNavigate(
                WellKnownRegionNames.CodeFileRegion,
                new Uri(WellKnownViewNames.CodeFileView, UriKind.Relative),
                navigation =>
                {
                    if (navigation.Result != true)
                    {
                        throw new Exception(_languageService.FindResource(WellKnownResourceKeys.CodeFileWindowNavigationFailedMessage));
                    }
                },
                new NavigationParameters
                {
                    {WellKnownParameterKeys.FileName, codeFileViewModel.Name}
                });

            var messageResult = _messageService.ShowYesNoCancelQuestion(null, _languageService.FindResource(WellKnownResourceKeys.DoYouWantToSaveChanges));
            if (messageResult == null)
                return;

            if (messageResult == true)
                if (!Save(codeFileViewModel))
                    return;
        }
        FinishInteraction?.Invoke();
    }

I bind this command on a button, but problem is user also can close it from windows standard close button. How can i call this method from popup window's WRAPPER(HOST) WINDOW's close button?

Upvotes: 0

Views: 471

Answers (0)

Related Questions