Skip to content

Commit 6800b1c

Browse files
authored
Fix: Always set content dialog root (#13859)
1 parent 12391aa commit 6800b1c

File tree

6 files changed

+37
-1
lines changed

6 files changed

+37
-1
lines changed

src/Files.App/Actions/Content/Archives/Compress/CompressIntoArchiveAction.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using Files.App.Dialogs;
55
using Microsoft.UI.Xaml.Controls;
6+
using Windows.Foundation.Metadata;
67

78
namespace Files.App.Actions
89
{
@@ -30,6 +31,9 @@ public override async Task ExecuteAsync()
3031
FileName = fileName,
3132
};
3233

34+
if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
35+
dialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;
36+
3337
var result = await dialog.TryShowAsync();
3438

3539
if (!dialog.CanCreate || result != ContentDialogResult.Primary)

src/Files.App/Services/UpdateService.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Microsoft.UI.Xaml.Controls;
77
using System.IO;
88
using System.Net.Http;
9+
using Windows.Foundation.Metadata;
910
using Windows.Services.Store;
1011
using Windows.Storage;
1112
using WinRT.Interop;
@@ -146,6 +147,9 @@ private static async Task<bool> ShowDialogAsync()
146147
PrimaryButtonText = "ConsentDialogPrimaryButtonText".GetLocalizedResource()
147148
};
148149

150+
if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
151+
dialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;
152+
149153
ContentDialogResult result = await dialog.TryShowAsync();
150154

151155
return result == ContentDialogResult.Primary;

src/Files.App/Utils/Archives/DecompressHelper.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using SevenZip;
99
using System.IO;
1010
using System.Text;
11+
using Windows.Foundation.Metadata;
1112
using Windows.Storage;
1213

1314
namespace Files.App.Utils.Archives
@@ -145,6 +146,9 @@ public static async Task DecompressArchiveAsync(IShellPage associatedInstance)
145146
};
146147
decompressArchiveDialog.ViewModel = decompressArchiveViewModel;
147148

149+
if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
150+
decompressArchiveDialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;
151+
148152
ContentDialogResult option = await decompressArchiveDialog.TryShowAsync();
149153
if (option != ContentDialogResult.Primary)
150154
return;
@@ -196,6 +200,9 @@ public static async Task DecompressArchiveHereAsync(IShellPage associatedInstanc
196200

197201
decompressArchiveDialog.ViewModel = decompressArchiveViewModel;
198202

203+
if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
204+
decompressArchiveDialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;
205+
199206
ContentDialogResult option = await decompressArchiveDialog.TryShowAsync();
200207
if (option != ContentDialogResult.Primary)
201208
return;
@@ -233,6 +240,9 @@ public static async Task DecompressArchiveToChildFolderAsync(IShellPage associat
233240
};
234241
decompressArchiveDialog.ViewModel = decompressArchiveViewModel;
235242

243+
if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
244+
decompressArchiveDialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;
245+
236246
ContentDialogResult option = await decompressArchiveDialog.TryShowAsync();
237247
if (option != ContentDialogResult.Primary)
238248
return;

src/Files.App/Utils/RecycleBin/RecycleBinHelpers.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Microsoft.UI.Xaml.Controls;
55
using System.Text.RegularExpressions;
66
using Vanara.PInvoke;
7+
using Windows.Foundation.Metadata;
78
using Windows.Storage;
89

910
namespace Files.App.Utils.RecycleBin
@@ -25,7 +26,7 @@ public static ulong GetSize()
2526
{
2627
return (ulong)Win32Shell.QueryRecycleBin().BinSize;
2728
}
28-
29+
2930
public static async Task<bool> IsRecycleBinItem(IStorageItem item)
3031
{
3132
List<ShellFileItem> recycleBinItems = await EnumerateRecycleBin();
@@ -55,6 +56,9 @@ public static async Task EmptyRecycleBinAsync()
5556
DefaultButton = ContentDialogButton.Primary
5657
};
5758

59+
if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
60+
ConfirmEmptyBinDialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;
61+
5862
// If the operation is approved by the user
5963
if (userSettingsService.FoldersSettingsService.DeleteConfirmationPolicy is DeleteConfirmationPolicies.Never ||
6064
await ConfirmEmptyBinDialog.TryShowAsync() == ContentDialogResult.Primary)
@@ -103,6 +107,9 @@ public static async Task RestoreSelectionRecycleBinAsync(IShellPage associatedIn
103107
DefaultButton = ContentDialogButton.Primary
104108
};
105109

110+
if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
111+
ConfirmEmptyBinDialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;
112+
106113
ContentDialogResult result = await ConfirmEmptyBinDialog.TryShowAsync();
107114

108115
if (result == ContentDialogResult.Primary)

src/Files.App/Utils/Storage/Operations/FilesystemOperations.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Microsoft.UI.Xaml.Controls;
66
using System.IO;
77
using System.Text;
8+
using Windows.Foundation.Metadata;
89
using Windows.Storage;
910

1011
namespace Files.App.Utils.Storage
@@ -146,6 +147,9 @@ await DialogDisplayHelper.ShowDialogAsync(
146147
CloseButtonText = "Cancel".GetLocalizedResource()
147148
};
148149

150+
if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
151+
dialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;
152+
149153
ContentDialogResult result = await dialog.TryShowAsync();
150154

151155
if (result == ContentDialogResult.Primary)
@@ -345,6 +349,9 @@ await DialogDisplayHelper.ShowDialogAsync(
345349
CloseButtonText = "Cancel".GetLocalizedResource()
346350
};
347351

352+
if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
353+
dialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;
354+
348355
ContentDialogResult result = await dialog.TryShowAsync();
349356

350357
if (result == ContentDialogResult.Primary)

src/Files.App/Views/MainPage.xaml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using Microsoft.UI.Xaml.Navigation;
1515
using System.Runtime.CompilerServices;
1616
using Windows.ApplicationModel;
17+
using Windows.Foundation.Metadata;
1718
using Windows.Services.Store;
1819
using WinRT.Interop;
1920
using VirtualKey = Windows.System.VirtualKey;
@@ -78,6 +79,9 @@ private async Task PromptForReviewAsync()
7879
SecondaryButtonText = "No".ToLocalized()
7980
};
8081

82+
if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
83+
promptForReviewDialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;
84+
8185
var result = await promptForReviewDialog.TryShowAsync();
8286

8387
if (result == ContentDialogResult.Primary)

0 commit comments

Comments
 (0)