diff --git a/src/Avalonia.Controls/TopLevel.cs b/src/Avalonia.Controls/TopLevel.cs
index ed11dec1d0..eea175eb3c 100644
--- a/src/Avalonia.Controls/TopLevel.cs
+++ b/src/Avalonia.Controls/TopLevel.cs
@@ -405,7 +405,31 @@ namespace Avalonia.Controls
{
return visual?.VisualRoot as TopLevel;
}
-
+
+ ///
+ /// Requests a to be inhibited.
+ /// The behavior remains inhibited until the return value is disposed.
+ /// The available set of s depends on the platform.
+ /// If a behavior is inhibited on a platform where this type is not supported the request will have no effect.
+ ///
+ public async Task RequestPlatformInhibition(PlatformInhibitionType type, string reason)
+ {
+ var platformBehaviorInhibition = PlatformImpl?.TryGetFeature();
+ if (platformBehaviorInhibition == null)
+ {
+ return Disposable.Create(() => { });
+ }
+
+ switch (type)
+ {
+ case PlatformInhibitionType.AppSleep:
+ await platformBehaviorInhibition.SetInhibitAppSleep(true, reason);
+ return Disposable.Create(() => platformBehaviorInhibition.SetInhibitAppSleep(false, reason).Wait());
+ default:
+ return Disposable.Create(() => { });
+ }
+ }
+
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
base.OnPropertyChanged(change);
@@ -571,30 +595,6 @@ namespace Avalonia.Controls
/// The event args.
protected virtual void OnClosed(EventArgs e) => Closed?.Invoke(this, e);
- ///
- /// Requests a to be inhibited.
- /// The behavior remains inhibited until the return value is disposed.
- /// The available set of s depends on the platform.
- /// If a behavior is inhibited on a platform where this type is not supported the request will have no effect.
- ///
- protected async Task RequestPlatformInhibition(PlatformInhibitionType type, string reason)
- {
- var platformBehaviorInhibition = PlatformImpl?.TryGetFeature();
- if (platformBehaviorInhibition == null)
- {
- return Disposable.Create(() => { });
- }
-
- switch (type)
- {
- case PlatformInhibitionType.AppSleep:
- await platformBehaviorInhibition.SetInhibitAppSleep(true, reason);
- return Disposable.Create(() => platformBehaviorInhibition.SetInhibitAppSleep(false, reason).Wait());
- default:
- return Disposable.Create(() => { });
- }
- }
-
///
/// Tries to get a service from an , logging a
/// warning if not found.