Fixing dialog presentations.
This commit is contained in:
@@ -20,6 +20,8 @@ using Wino.Core.Requests;
|
|||||||
using Wino.Core.UWP.Extensions;
|
using Wino.Core.UWP.Extensions;
|
||||||
using Wino.Dialogs;
|
using Wino.Dialogs;
|
||||||
using Wino.Helpers;
|
using Wino.Helpers;
|
||||||
|
using Windows.Foundation.Metadata;
|
||||||
|
using Wino.Core.WinUI.Services;
|
||||||
|
|
||||||
#if NET8_0
|
#if NET8_0
|
||||||
using Microsoft.UI.Xaml.Controls;
|
using Microsoft.UI.Xaml.Controls;
|
||||||
@@ -34,10 +36,12 @@ namespace Wino.Services
|
|||||||
private SemaphoreSlim _presentationSemaphore = new SemaphoreSlim(1);
|
private SemaphoreSlim _presentationSemaphore = new SemaphoreSlim(1);
|
||||||
|
|
||||||
private readonly IThemeService _themeService;
|
private readonly IThemeService _themeService;
|
||||||
|
private readonly IAppShellService _appShellService;
|
||||||
|
|
||||||
public DialogService(IThemeService themeService)
|
public DialogService(IThemeService themeService, IAppShellService appShellService)
|
||||||
{
|
{
|
||||||
_themeService = themeService;
|
_themeService = themeService;
|
||||||
|
_appShellService = appShellService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowNotSupportedMessage()
|
public void ShowNotSupportedMessage()
|
||||||
@@ -52,9 +56,21 @@ namespace Wino.Services
|
|||||||
RequestedTheme = _themeService.RootTheme.ToWindowsElementTheme()
|
RequestedTheme = _themeService.RootTheme.ToWindowsElementTheme()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if NET8_0
|
||||||
|
AssignXamlRoot(dialog);
|
||||||
|
#endif
|
||||||
|
|
||||||
await HandleDialogPresentation(() => dialog.ShowDialogAsync(title, message));
|
await HandleDialogPresentation(() => dialog.ShowDialogAsync(title, message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AssignXamlRoot(ContentDialog dialog)
|
||||||
|
{
|
||||||
|
if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
|
||||||
|
{
|
||||||
|
dialog.XamlRoot = (_appShellService.AppWindow.Content).XamlRoot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Waits for PopupRoot to be available before presenting the dialog and returns the result after presentation.
|
/// Waits for PopupRoot to be available before presenting the dialog and returns the result after presentation.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -66,6 +82,9 @@ namespace Wino.Services
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#if NET8_0
|
||||||
|
AssignXamlRoot(dialog);
|
||||||
|
#endif
|
||||||
return await dialog.ShowAsync();
|
return await dialog.ShowAsync();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
Reference in New Issue
Block a user