Skip to content

Commit 119068c

Browse files
committed
Fix: Always set content dialog root
1 parent 49deb0c commit 119068c

File tree

5 files changed

+45
-0
lines changed

5 files changed

+45
-0
lines changed

src/Files.App/Services/UpdateService.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,15 @@ private static async Task<bool> ShowDialogAsync()
151151
return result == ContentDialogResult.Primary;
152152
}
153153

154+
// WINUI3
155+
private ContentDialog SetContentDialogRoot(ContentDialog contentDialog)
156+
{
157+
if (Windows.Foundation.Metadata.ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
158+
contentDialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;
159+
160+
return contentDialog;
161+
}
162+
154163
public async Task CheckLatestReleaseNotesAsync(CancellationToken cancellationToken = default)
155164
{
156165
if (!IsAppUpdated)

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,15 @@ public static async Task DecompressArchiveToChildFolderAsync(IShellPage associat
247247
}
248248
}
249249

250+
// WINUI3
251+
private static ContentDialog SetContentDialogRoot(ContentDialog contentDialog)
252+
{
253+
if (Windows.Foundation.Metadata.ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
254+
contentDialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;
255+
256+
return contentDialog;
257+
}
258+
250259
private static async Task<SevenZipExtractor?> GetZipFile(BaseStorageFile archive, string password = "")
251260
{
252261
return await FilesystemTasks.Wrap(async () =>

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,15 @@ public static async Task RestoreSelectionRecycleBinAsync(IShellPage associatedIn
109109
await RestoreItemAsync(associatedInstance);
110110
}
111111

112+
// WINUI3
113+
private static ContentDialog SetContentDialogRoot(ContentDialog contentDialog)
114+
{
115+
if (Windows.Foundation.Metadata.ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
116+
contentDialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;
117+
118+
return contentDialog;
119+
}
120+
112121
public static async Task<bool> HasRecycleBin(string? path)
113122
{
114123
if (string.IsNullOrEmpty(path) || path.StartsWith(@"\\?\", StringComparison.Ordinal))

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,15 @@ await rawStorageHistory.SelectMany((item) => item.Source).ToListAsync(),
937937
return null;
938938
}
939939

940+
// WINUI3
941+
private ContentDialog SetContentDialogRoot(ContentDialog contentDialog)
942+
{
943+
if (Windows.Foundation.Metadata.ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
944+
contentDialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;
945+
946+
return contentDialog;
947+
}
948+
940949
public Task<IStorageHistory> CreateShortcutItemsAsync(IList<IStorageItemWithPath> source, IList<string> destination, IProgress<StatusCenterItemProgressModel> progress, CancellationToken token)
941950
{
942951
throw new NotImplementedException("Cannot create shortcuts in UWP.");

src/Files.App/Views/LayoutModes/StandardLayoutMode.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,15 @@ protected void SelectionCheckbox_DoubleTapped(object sender, DoubleTappedRoutedE
332332
e.Handled = true;
333333
}
334334

335+
// WINUI3
336+
private ContentDialog SetContentDialogRoot(ContentDialog contentDialog)
337+
{
338+
if (Windows.Foundation.Metadata.ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
339+
contentDialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;
340+
341+
return contentDialog;
342+
}
343+
335344
public override void Dispose()
336345
{
337346
base.Dispose();

0 commit comments

Comments
 (0)