diff --git a/src/modules/peek/Peek.FilePreviewer/FilePreview.xaml b/src/modules/peek/Peek.FilePreviewer/FilePreview.xaml
index 52ad6b435cd..20d78310eb9 100644
--- a/src/modules/peek/Peek.FilePreviewer/FilePreview.xaml
+++ b/src/modules/peek/Peek.FilePreviewer/FilePreview.xaml
@@ -30,8 +30,12 @@
MaxWidth="{x:Bind ImagePreviewer.MaxImageSize.Width, Mode=OneWay}"
MaxHeight="{x:Bind ImagePreviewer.MaxImageSize.Height, Mode=OneWay}"
Source="{x:Bind ImagePreviewer.Preview, Mode=OneWay}"
- ToolTipService.ToolTip="{x:Bind InfoTooltip, Mode=OneWay}"
- Visibility="{x:Bind IsPreviewVisible(ImagePreviewer, Previewer.State), Mode=OneWay}" />
+ Visibility="{x:Bind IsPreviewVisible(ImagePreviewer, Previewer.State), Mode=OneWay}"
+ PointerMoved="ToolTipParentControl_PointerMoved">
+
+
+
+
+ Visibility="{x:Bind IsPreviewVisible(VideoPreviewer, Previewer.State), Mode=OneWay}"
+ PointerMoved="ToolTipParentControl_PointerMoved">
+
+
+
diff --git a/src/modules/peek/Peek.FilePreviewer/FilePreview.xaml.cs b/src/modules/peek/Peek.FilePreviewer/FilePreview.xaml.cs
index 23874d8ca8c..7db7582c6f4 100644
--- a/src/modules/peek/Peek.FilePreviewer/FilePreview.xaml.cs
+++ b/src/modules/peek/Peek.FilePreviewer/FilePreview.xaml.cs
@@ -12,6 +12,7 @@
using Microsoft.PowerToys.Telemetry;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
+using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Input;
using Microsoft.Web.WebView2.Core;
using Peek.Common.Extensions;
@@ -336,10 +337,8 @@ private async Task UpdateTooltipAsync(CancellationToken cancellationToken)
}
// Fetch and format available file properties
- var sb = new StringBuilder();
-
string fileNameFormatted = ReadableStringHelper.FormatResourceString("PreviewTooltip_FileName", Item.Name);
- sb.Append(fileNameFormatted);
+ var sb = new StringBuilder(fileNameFormatted, 256);
cancellationToken.ThrowIfCancellationRequested();
string fileType = await Task.Run(Item.GetContentTypeAsync);
@@ -356,5 +355,23 @@ private async Task UpdateTooltipAsync(CancellationToken cancellationToken)
InfoTooltip = sb.ToString();
}
+
+ ///
+ /// Set the placement of the tooltip for those previewers supporting the feature, ensuring it does not obscure the Main Window's title bar.
+ ///
+ private void ToolTipParentControl_PointerMoved(object sender, PointerRoutedEventArgs e)
+ {
+ var previewControl = sender as FrameworkElement;
+ if (previewControl != null)
+ {
+ var toolTip = ToolTipService.GetToolTip(previewControl) as ToolTip;
+ if (toolTip != null)
+ {
+ var pos = e.GetCurrentPoint(previewControl).Position;
+ toolTip.Placement = pos.Y < previewControl.ActualHeight / 2 ?
+ PlacementMode.Bottom : PlacementMode.Top;
+ }
+ }
+ }
}
}