From e86f101103863f263e8753dad17d463a615f7083 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Tue, 15 Jun 2021 22:32:33 +0800 Subject: [PATCH] minor modify TextBlockAttach I'm not sure this is a good solution --- .../HandyControl_Shared/Controls/Attach/TextBlockAttach.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Shared/HandyControl_Shared/Controls/Attach/TextBlockAttach.cs b/src/Shared/HandyControl_Shared/Controls/Attach/TextBlockAttach.cs index 9ec37a0d..3e5236db 100644 --- a/src/Shared/HandyControl_Shared/Controls/Attach/TextBlockAttach.cs +++ b/src/Shared/HandyControl_Shared/Controls/Attach/TextBlockAttach.cs @@ -1,4 +1,5 @@ -using System.Windows; +using System; +using System.Windows; using System.Windows.Controls; using System.Windows.Media; using HandyControl.Data; @@ -46,7 +47,9 @@ namespace HandyControl.Controls textBlock.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); var width = textBlock.DesiredSize.Width - textBlock.Margin.Left - textBlock.Margin.Right; - if (textBlock.RenderSize.Width > width || textBlock.ActualWidth < width || CalcTextWidth(textBlock) > width) + // the code Math.Abs(CalcTextWidth(textBlock) - width) > 1 is not elegant end even bugly, + // while it does solve the problem of Tooltip failure in some cases + if (textBlock.RenderSize.Width > width || textBlock.ActualWidth < width || Math.Abs(CalcTextWidth(textBlock) - width) > 1) { ToolTipService.SetToolTip(textBlock, textBlock.Text); }