From 10297be089975b06b591e25d273d2d4a56a6c0ac Mon Sep 17 00:00:00 2001 From: punker76 Date: Wed, 24 Jun 2020 00:15:31 +0200 Subject: [PATCH] (GH-3865) Fix InvalidOperationException when open a dialog over a child window --- src/MahApps.Metro/Controls/Dialogs/DialogManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MahApps.Metro/Controls/Dialogs/DialogManager.cs b/src/MahApps.Metro/Controls/Dialogs/DialogManager.cs index b95a96ad02..22294be286 100644 --- a/src/MahApps.Metro/Controls/Dialogs/DialogManager.cs +++ b/src/MahApps.Metro/Controls/Dialogs/DialogManager.cs @@ -501,7 +501,7 @@ private static void AddDialog(this MetroWindow window, BaseMetroDialog dialog) window.StoreFocus(); // if there's already an active dialog, move to the background - var activeDialog = window.metroActiveDialogContainer.Children.Cast().SingleOrDefault(); + var activeDialog = window.metroActiveDialogContainer.Children.OfType().SingleOrDefault(); if (activeDialog != null) { window.metroActiveDialogContainer.Children.Remove(activeDialog); @@ -520,7 +520,7 @@ private static void RemoveDialog(this MetroWindow window, BaseMetroDialog dialog window.metroActiveDialogContainer.Children.Remove(dialog); //remove the dialog from the container // if there's an inactive dialog, bring it to the front - var dlg = window.metroInactiveDialogContainer.Children.Cast().LastOrDefault(); + var dlg = window.metroInactiveDialogContainer.Children.OfType().LastOrDefault(); if (dlg != null) { window.metroInactiveDialogContainer.Children.Remove(dlg);