简体   繁体   中英

Can't see Loaded, Initialized, Visible window

Simplified version

  1. ParentWindow.ShowDialog()
  2. Click default/Bring Up Child Window button in ParentWindow
  3. Click event handler for default/Bring Up Child Window button does ParentWindow.Hide()
  4. ChildWindow.ShowDialog()
  5. Click ChildWindow's cancel/Go Back button
  6. ParentWindow.Visibility = Visibility.Visible
  7. ParentWindow is nowhere to be found.

I checked, and ParentWindow returns true for IsInitialized , IsLoaded , and IsVisible . I also Alt-Tabbed my way through all my windows to look for it - it's not hiding under anything.

Why can't I see ParentWindow anywhere?


Full version

  1. parseSettingsWindow.ShowDialog()
  2. Click default/Bring Up Fix Selector button in parseSettingsWindow
  3. Click event handler for default/Bring Up Fix Selector button does: a. ParentWindow.Hide() b. parseSettingsWindow.GoToNextWindow flag set to true (Next window is Fix Selector)
  4. while loop does fixSelector.ShowDialog() because it's not yet loaded
  5. Click ChildWindow's cancel/Go Back button
  6. while loop is entered again, goes to `case "Parse Settings" section
  7. parseSettingsWindow.Visibility = Visibility.Visible
  8. parseSettingsWindow is nowhere to be found

I checked, and parseSettingsWindow returns true for IsInitialized , IsLoaded , and IsVisible in the Immediate Window when pausing execution on the break; line of the "Parse Settings" while loop section. I also Alt-Tabbed my way through all my windows to look for it - it's not hiding under anything.

Why can't I see parseSettingsWindow anywhere?


Main class

    public static bool UserPromptedSettingsWereWrittenToModel(ref Model model, ref ActiveFixes activeFixes, ref ActiveReports activeReports)
    {
        var viewModel = new ViewModel();

        var parseSettingsWindow = new ViewPlusViewModel.ParseSettings();
        parseSettingsWindow.InitializeComponent();

        var fixSelector = new ViewPlusViewModel.FixSelector(viewModel);
        fixSelector.InitializeComponent();

        var seeAllFixesReports = new ViewPlusViewModel.SeeAllFixesReports();
        seeAllFixesReports.InitializeComponent();


        parseSettingsWindow.ShowDialog();
        var nextWindowToOpen = "Fix Selector";


        while (parseSettingsWindow.GoToNextWindow == true && fixSelector.GoToNextWindow == false)
        {
            switch(nextWindowToOpen)
            {
                case "Fix Selector":
                    if (fixSelector.IsLoaded)
                    {
                        fixSelector.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        fixSelector.ShowDialog();
                    }

                    nextWindowToOpen = "Parse Settings";
                    break;
                case "Parse Settings":
                    parseSettingsWindow.GoToNextWindow = false;
                    parseSettingsWindow.Visibility = Visibility.Visible;
                    nextWindowToOpen = "Fix Selector";
                    break;
            }
        }


        if (parseSettingsWindow.GoToNextWindow == false)
        {
            parseSettingsWindow.Close();
            if (fixSelector.IsLoaded) fixSelector.Close();
            if (seeAllFixesReports.IsLoaded) { seeAllFixesReports.Close(); }
            return false;
        }

        parseSettingsWindow.Close();
        fixSelector.Close();
        if (seeAllFixesReports.IsLoaded) { seeAllFixesReports.Close(); }

        return true;
    }

ParseSettingsWindow.cs

    private void GoToNextWindow_Click(object sender, RoutedEventArgs e)
    {
        this.GoToNextWindow = true;
        this.Hide();
    }

You can't bring a hidden .ShowDialog() window back again via Window.Visibility . You need to use .ShowDialog() on it again. In addition, any buttons given the IsCancel = True property will no longer have that functionality even when using ShowDialog() again, so presses on that button will need to be handled manually.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM