diff --git a/src/modules/peek/Peek.FilePreviewer/FilePreview.xaml b/src/modules/peek/Peek.FilePreviewer/FilePreview.xaml
index 52ad6b435c..9943a6962d 100644
--- a/src/modules/peek/Peek.FilePreviewer/FilePreview.xaml
+++ b/src/modules/peek/Peek.FilePreviewer/FilePreview.xaml
@@ -29,18 +29,25 @@
x:Name="ImagePreview"
MaxWidth="{x:Bind ImagePreviewer.MaxImageSize.Width, Mode=OneWay}"
MaxHeight="{x:Bind ImagePreviewer.MaxImageSize.Height, Mode=OneWay}"
+ PointerMoved="ToolTipParentControl_PointerMoved"
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}">
+
+
+
+
+
+
+
diff --git a/src/modules/peek/Peek.FilePreviewer/FilePreview.xaml.cs b/src/modules/peek/Peek.FilePreviewer/FilePreview.xaml.cs
index 53d96e5eb6..cb776fc277 100644
--- a/src/modules/peek/Peek.FilePreviewer/FilePreview.xaml.cs
+++ b/src/modules/peek/Peek.FilePreviewer/FilePreview.xaml.cs
@@ -13,6 +13,7 @@ using ManagedCommon;
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;
@@ -340,10 +341,8 @@ namespace Peek.FilePreviewer
}
// 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);
@@ -360,5 +359,23 @@ namespace Peek.FilePreviewer
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;
+ }
+ }
+ }
}
}