0

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?

Aytaç Aşan
  • 155
  • 13
  • @kennyzx No this is not duplicated question! I know how can i handle close button of window with MVVM pattern. I'm clearly asking access prisim's WRAPPER(HOST) WINDOW's close button... My question is related PRISM more than WPF&MVVM. If you think still it's same thing please show me how can i do accomplish... – Aytaç Aşan Jun 23 '17 at 09:05
  • Also this link https://stackoverflow.com/questions/3683450/handling-the-window-closing-event-with-wpf-mvvm-light-toolkit is more related to my question. Plus it's showing usage of PassEventArgsToCommand property and handling CancelEventArgs's Cancel property. – Aytaç Aşan Jun 23 '17 at 09:16

0 Answers0